Ejemplo n.º 1
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(TextBox_result.Text))
     {
         ActionToClose?.Invoke();
         ActionToDo?.Invoke(TextBox_result.Text);
     }
 }
Ejemplo n.º 2
0
        private void buttonExtSet_Click(object sender, EventArgs e)
        {
            List <int> currentsel = imageViewer.Selection;

            System.Diagnostics.Debug.WriteLine("Initial Sectors " + string.Join(",", initiallist));
            System.Diagnostics.Debug.WriteLine("Cur Sectors " + string.Join(",", currentsel));
            bool added = currentsel.Except(initiallist).Any(); // if initial list does not include a current sel

            if (added)                                         // we added some..
            {
                if (ExtendedControls.MessageBoxTheme.Show(this,
                                                          ("You have added new sectors!" + Environment.NewLine + "This will require a complete re-download of the EDSM data" + Environment.NewLine + "Confirm you wish to do this?").T(EDTx.GalaxySectorSelect_RD),
                                                          "Warning".T(EDTx.Warning), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    if (!EDDConfig.Instance.EDSMEDDBDownload)
                    {
                        ExtendedControls.MessageBoxTheme.Show(this, ("Synchronisation to star data disabled in settings." + Environment.NewLine + "Reenable to allow star data to be updated").T(EDTx.GalaxySectorSelect_NoSync), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }

                    Action = ActionToDo.Add;
                }
                else
                {
                    return;
                }
            }
            else
            {
                Removed = initiallist.Except(currentsel).ToList();  // if initial list does not include a current sel

                if (Removed.Any())
                {
                    AllRemoveSectors = (from int i in GridId.AllId() where !currentsel.Contains(i) select i).ToList();

                    if (ExtendedControls.MessageBoxTheme.Show(this,
                                                              ("You have removed sectors!" + Environment.NewLine + "This will require the DB to be cleaned of entries, which will take time" + Environment.NewLine + "Confirm you wish to do this?").T(EDTx.GalaxySectorSelect_RS),
                                                              "Warning".T(EDTx.Warning), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                    {
                        Action = ActionToDo.Remove;
                    }
                    else
                    {
                        return;
                    }

                    Action = ActionToDo.Remove;
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     ActionToClose?.Invoke();
     ActionToDo?.Invoke(TextBox_result.Text);
 }
Ejemplo n.º 4
0
        static bool ParseArgs(string[] args)
        {
            int          cpt;
            int          actionCounter = 0;
            Assembly     thisAssem     = typeof(Program).Assembly;
            AssemblyName thisAssemName = thisAssem.GetName();

            for (cpt = 0; cpt < args.Length; cpt++)
            {
                if (!args[cpt].StartsWith("-"))
                {
                    /* save action to perform */
                    if (actionCounter > MAX_ACTION_COUNTER)
                    {
                        break;
                    }

                    Actions[actionCounter++] = args[cpt];
                }
            }
            String Action = Actions[0];

            for (actionCounter = 0; actionCounter < MAX_ACTION_COUNTER; actionCounter++)
            {
                Action = Actions[actionCounter];
                if (Action != null)
                {
                    switch (Action.ToLower())
                    {
                    case "new":
                        _actions_to_do |= ActionToDo.actNew;
                        break;

                    case "format":
                        _actions_to_do |= ActionToDo.actFormat;
                        break;

                    case "disable":
                        _actions_to_do |= ActionToDo.actDisable;
                        break;

                    case "read":
                        _actions_to_do |= ActionToDo.actRead;
                        break;

                    case "check":
                        _actions_to_do |= ActionToDo.actCheck;
                        break;

                    case "list-readers":
                        _actions_to_do |= ActionToDo.actList;
                        break;

                    case "loadkey":
                        _actions_to_do |= ActionToDo.actLoadMasterKey;
                        break;

                    case "newdam":
                        _actions_to_do |= ActionToDo.actNewDam;
                        break;

                    case "newdamalone":
                        _actions_to_do |= ActionToDo.actNewDamAlone;
                        break;

                    case "erasedam":
                        _actions_to_do |= ActionToDo.actEraseDam;
                        break;

                    case "freedam":
                        _actions_to_do |= ActionToDo.actFreeDam;
                        break;

                    case "dammac":
                        _actions_to_do |= ActionToDo.actDammac;
                        break;

                    default:
                        break;
                    }
                }
            }

            int c;

            List <LongOpt> options = new List <LongOpt>();

            options.Add(new LongOpt("reader", Argument.Required, null, 'r'));
            options.Add(new LongOpt("master-key", Argument.Required, null, 'm'));
            options.Add(new LongOpt("n-enck", Argument.Required, null, 'n'));
            options.Add(new LongOpt("q-dammac", Argument.Required, null, 'q'));
            options.Add(new LongOpt("w-divert-key", Argument.Required, null, 'w'));
            options.Add(new LongOpt("x-damauth-key", Argument.Required, null, 'x'));
            options.Add(new LongOpt("y-dammac-key", Argument.Required, null, 'y'));
            options.Add(new LongOpt("z-damenc-key", Argument.Required, null, 'z'));
            options.Add(new LongOpt("dueinfo-key", Argument.Required, null, 'd'));

            options.Add(new LongOpt("escn", Argument.Required, null, 'e'));
            options.Add(new LongOpt("uid", Argument.Required, null, 'u'));

            options.Add(new LongOpt("iso", Argument.No, null, 'i'));
            options.Add(new LongOpt("verbose", Argument.Optional, null, 'v'));
            options.Add(new LongOpt("pause", Argument.No, null, 'p'));
            options.Add(new LongOpt("help", Argument.No, null, 'h'));

            Getopt g = new Getopt(thisAssemName.Name, args, "r:m:n:q:w:x:y:z:d:e:u:ivph", options.ToArray());

            g.Opterr = true;

            while ((c = g.getopt()) != -1)
            {
                string arg = g.Optarg;
                if ((arg != null) && (arg.StartsWith("=")))
                {
                    arg = arg.Substring(1);
                }

                switch (c)
                {
                case 'v':
                    if (arg != null)
                    {
                        int level;
                        if (int.TryParse(arg, out level))
                        {
                            Logger.ConsoleLevel = Logger.IntToLevel(level);
                        }
                    }
                    break;

                case 'p':
                    _actions_to_do |= ActionToDo.actPause;
                    break;

                case 'h':
                    Help();
                    return(true);

                case 'i':
                    _iso_enable = true;
                    break;

                case 'r':    /* reader */
                    if (int.TryParse(arg, out _reader_id) == false)
                    {
                        _reader_id = -1;
                    }
                    break;

                case 'm':    /* master ker */
                    if (arg.Length != 32)
                    {
                        Console.WriteLine("Aes key size error {0}.", arg.Length);
                        return(false);
                    }
                    _aes_master_key = arg;
                    break;

                /*case 'n':// new master ker
                 *  if (arg.Length != 32)
                 *  {
                 *      Console.WriteLine("Aes key size error {0}.", arg.Length);
                 *      return false;
                 *  }
                 *  _aes_new_master_key = arg;
                 *  break;*/
                case 'd':    /* diversification key */
                    if (arg.Length != 32)
                    {
                        Console.WriteLine("dueinfo-key size error {0}.", arg.Length);
                        return(false);
                    }
                    _aes_base_key = arg;
                    break;

                case 'e':     /* escn ID */
                    _escn_id = arg;
                    break;

                case 'u':     /* UID */
                    _card_uid = arg;
                    break;

                case 'x':     /* PICCDAMAuthKey */
                    if (arg.Length != 32)
                    {
                        Console.WriteLine("DAM auth-key size error {0}.", arg.Length);
                        return(false);
                    }
                    _dam_auth_key = arg;
                    break;

                case 'y':     /* PICCDAMMACKey */
                    if (arg.Length != 32)
                    {
                        Console.WriteLine("DAM enc-key size error {0}.", arg.Length);
                        return(false);
                    }
                    _dam_mac_key = arg;
                    break;

                case 'z':     /* PICCDAMENCKey */
                    if (arg.Length != 32)
                    {
                        Console.WriteLine("DAM mac-key size error {0}.", arg.Length);
                        return(false);
                    }
                    _dam_enc_key = arg;
                    break;

                case 'w':     /* proprietary root base key used for diversification */
                    if (arg.Length != 32)
                    {
                        Console.WriteLine("Root diversification base key error size error {0}.", arg.Length);
                        return(false);
                    }
                    _aes_owner_divert_root_key = arg;
                    break;

                case 'n':     /*  */
                    if (arg.Length == 0)
                    {
                        Console.WriteLine("ENCK error size error {0}.", arg.Length);
                        return(false);
                    }
                    _dam_enck = arg;
                    break;

                case 'q':     /*  */
                    if (arg.Length != 16)
                    {
                        Console.WriteLine("DAMMAC error size error {0}.", arg.Length);
                        return(false);
                    }
                    _dam_dammac = arg;
                    break;

                default:
                    goto syntax_error;
                }
            }

            if (_actions_to_do == 0x0000)
            {
                Console.WriteLine("No action requested. Try {0} --help for help.", thisAssemName.Name);
                return(false);
            }

            return(true);

syntax_error:
            Console.WriteLine("Syntax error. Try {0} --help for help.", thisAssemName.Name);
            return(false);
        }
Ejemplo n.º 5
0
        static bool ParseArgs(string[] args)
        {
            int          cpt;
            int          actionCounter = 0;
            Assembly     thisAssem     = typeof(Program).Assembly;
            AssemblyName thisAssemName = thisAssem.GetName();

            for (cpt = 0; cpt < args.Length; cpt++)
            {
                if (!args[cpt].StartsWith("-"))
                {
                    /* save action to perform */
                    if (actionCounter > MAX_ACTION_COUNTER)
                    {
                        break;
                    }

                    Actions[actionCounter++] = args[cpt];
                }
            }
            String Action = Actions[0];

            for (actionCounter = 0; actionCounter < MAX_ACTION_COUNTER; actionCounter++)
            {
                Action = Actions[actionCounter];
                if (Action != null)
                {
                    switch (Action.ToLower())
                    {
                    case "new":
                        _actions_to_do |= ActionToDo.actNew;
                        break;

                    case "disable":
                        _actions_to_do |= ActionToDo.actDisable;
                        break;

                    case "read":
                        _actions_to_do |= ActionToDo.actRead;
                        break;

                    case "check":
                        _actions_to_do |= ActionToDo.actCheck;
                        break;

                    case "list-readers":
                        _actions_to_do |= ActionToDo.actList;
                        break;

                    case "divert":
                        _actions_to_do |= ActionToDo.actDiversification;
                        break;

                    default:
                        break;
                    }
                }
            }

            int c;

            List <LongOpt> options = new List <LongOpt>();

            options.Add(new LongOpt("reader", Argument.Required, null, 'r'));
            options.Add(new LongOpt("master-key", Argument.Required, null, 'm'));
            options.Add(new LongOpt("dueinfo-key", Argument.Required, null, 'd'));
            options.Add(new LongOpt("escn", Argument.Required, null, 'e'));

            options.Add(new LongOpt("iso", Argument.No, null, 'i'));
            options.Add(new LongOpt("verbose", Argument.Optional, null, 'v'));
            options.Add(new LongOpt("pause", Argument.No, null, 'p'));
            options.Add(new LongOpt("help", Argument.No, null, 'h'));

            Getopt g = new Getopt(thisAssemName.Name, args, "r:m:d:e:ivph", options.ToArray());

            g.Opterr = true;

            while ((c = g.getopt()) != -1)
            {
                string arg = g.Optarg;
                if ((arg != null) && (arg.StartsWith("=")))
                {
                    arg = arg.Substring(1);
                }

                switch (c)
                {
                case 'v':
                    if (arg != null)
                    {
                        int level;
                        if (int.TryParse(arg, out level))
                        {
                            Logger.ConsoleLevel = Logger.IntToLevel(level);
                        }
                    }
                    break;

                case 'p':
                    _actions_to_do |= ActionToDo.actPause;
                    break;

                case 'h':
                    Help();
                    return(true);

                case 'i':
                    _iso_enable = true;
                    break;

                case 'r':    /* reader */
                    if (int.TryParse(arg, out _reader_id) == false)
                    {
                        _reader_id = -1;
                    }
                    break;

                case 'm':    /* master ker */
                    if (arg.Length != 32)
                    {
                        Console.WriteLine("Aes key size error {0}.", arg.Length);
                        return(false);
                    }
                    _aes_master_key = arg;
                    break;

                case 'd':    /* diversification key */
                    if (arg.Length != 32)
                    {
                        Console.WriteLine("dueinfo-key size error {0}.", arg.Length);
                        return(false);
                    }
                    _aes_base_key = arg;
                    break;

                case 'e':     /* escn ID */
                    _escn_id = arg;
                    break;

                default:
                    goto syntax_error;
                }
            }

            if (_actions_to_do == 0x0000)
            {
                Console.WriteLine("No action requested. Try {0} --help for help.", thisAssemName.Name);
                return(false);
            }

            return(true);

syntax_error:
            Console.WriteLine("Syntax error. Try {0} --help for help.", thisAssemName.Name);
            return(false);
        }