Example #1
0
        public EditProgWindow(ProgList progList, int id = -1)
        {
            InitializeComponent();
            this.AcceptButton = this.saveButton;
            this.CancelButton = this.cancelButton;
            _progList = progList;

            if (!JumpListHelper.IsSupported())
            {
                jumpListLabel.Hide();
                jumpListLabelState.Hide();
                jumpListBox.Hide();
            }

            if (id < 0)
            {
                this.Text = Localization.Strings.AddProgram;
                _prog = _progList.CreateProg();
                _isNew = true;
            }
            else
            {
                this.Text = Localization.Strings.EditProgram;
                _prog = progList.Get(id);
                _isNew = false;
                this.nameField.Text = _prog.Name;
                this.pathField.Text = _prog.Path;
                this.argsField.Text = _prog.Args;
                this.diskImageField.Text = _prog.DiskImage;
                this.iconField.Text = _prog.Icon;
                this.jumpListBox.Checked = _prog.InJumpList;

                updateIconPreview();
            }
        }
Example #2
0
 public bool Add(Prog program)
 {
     if (!program.IsOK())
     {
         return(false);
     }
     _progs.Add(program);
     return(Save(this));
 }
Example #3
0
 public Prog(Prog program)
 {
     _id         = program.ID;
     _name       = program.Name;
     _path       = program.Path;
     _args       = program.Args;
     _diskImage  = program.DiskImage;
     _icon       = program.Icon;
     _inJumpList = program.InJumpList;
 }
Example #4
0
 public Prog(Prog program)
 {
     _id = program.ID;
     _name = program.Name;
     _path = program.Path;
     _args = program.Args;
     _diskImage = program.DiskImage;
     _icon = program.Icon;
     _inJumpList = program.InJumpList;
 }
Example #5
0
        public static void CreateShortcut(Prog prog)
        {
            var shell = new WshShell();
            string shortcutName = "<>:\"/\\|?*".ToCharArray().Union(Path.GetInvalidFileNameChars()).Aggregate(prog.Name, (current, c) => current.Replace(c.ToString(CultureInfo.InvariantCulture), ""));

            string shortcutAddress = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), shortcutName + ".lnk");

            var shortcut = (IWshShortcut)shell.CreateShortcut(shortcutAddress);
            shortcut.Description = prog.Name + " via DTWrapper";
            shortcut.TargetPath = System.Reflection.Assembly.GetEntryAssembly().Location;
            shortcut.Arguments = "start " + prog.ID;
            shortcut.IconLocation = prog.Icon;
            shortcut.WorkingDirectory = Environment.CurrentDirectory;
            shortcut.Save();
        }
Example #6
0
 public bool Update(Prog program)
 {
     try
     {
         int index = _progs.IndexOf(Get(program.ID));
         _progs.RemoveAt(index);
         _progs.Insert(index, program);
         return(Save(this));
     }
     catch (Exception e)
     {
         LogHelper.WriteLine(e.Message + Environment.NewLine + e.StackTrace);
         return(false);
     }
 }
Example #7
0
 public bool Add(Prog program)
 {
     if (!program.IsOK()) return false;
     _progs.Add(program);
     return Save(this);
 }
Example #8
0
 public bool Update(Prog program)
 {
     try
     {
         int index = _progs.IndexOf(Get(program.ID));
         _progs.RemoveAt(index);
         _progs.Insert(index, program);
         return Save(this);
     }
     catch (Exception e)
     {
         LogHelper.WriteLine(e.Message + Environment.NewLine + e.StackTrace);
         return false;
     }
 }
Example #9
0
 public bool Del(Prog program)
 {
     return (_progs.Remove(program) && Save(this));
 }
Example #10
0
 public bool Del(Prog program)
 {
     return(_progs.Remove(program) && Save(this));
 }