示例#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();
            }
        }
示例#2
0
        public static void Update()
        {
            if (IsSupported())
            {
                JumpList    jumpList = JumpList.CreateJumpList();
                List <Prog> progs    = new ProgList().GetJumpList();
                progs.Reverse();

                foreach (Prog prog in progs)
                {
                    var task = new JumpListLink(System.Reflection.Assembly.GetEntryAssembly().Location, prog.Name)
                    {
                        Arguments = "start " + prog.ID
                    };
                    if (File.Exists(prog.Icon))
                    {
                        task.IconReference = new IconReference(@prog.Icon, 0);
                    }
                    task.WorkingDirectory = Environment.CurrentDirectory;
                    jumpList.AddUserTasks(task);
                }

                jumpList.Refresh();
            }
        }
示例#3
0
        private void advTree1_NodeMouseUp(object sender, DevComponents.AdvTree.TreeNodeMouseEventArgs e)
        {
            ProgList _mproglist = e.Node.Tag as ProgList;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                string _FrmName = string.Empty;
                if (!string.IsNullOrEmpty(_mproglist.Prog_Assmbly.Trim()))//程序集
                {
                    _FrmName = _mproglist.Prog_Assmbly.Trim() + ".";
                }
                if (!string.IsNullOrEmpty(_mproglist.Prog_NameSp.Trim()))//命名空间
                {
                    _FrmName += _mproglist.Prog_NameSp.Trim() + ".";
                }
                else
                {
                    _FrmName += this.GetType().Namespace + ".";
                }

                if (string.IsNullOrEmpty(_mproglist.Prog_CLS.Trim()))
                {
                    return;
                }
                else
                {
                    _FrmName += _mproglist.Prog_CLS.Trim();
                }

                bool CanNew = true;
                for (int i = 0; i < this.MdiChildren.Length; i++)
                {
                    if (this.MdiChildren[i].Name == _FrmName)
                    {
                        CanNew = false;
                        //this.MdiChildren[i].Focus();
                        this.MdiChildren[i].Activate();
                        break;
                    }
                }
                if (!CanNew)
                {
                    return;
                }
                Assembly assembly = Assembly.GetExecutingAssembly();

                Form _frm = assembly.CreateInstance(_FrmName) as Form;
                _frm.Name = _FrmName;
                formCount++;
                _frm.MdiParent = this;
                _frm.Text      = _mproglist.Prog_Descp;
                _frm.Show();

                xtraTabbedMdiManager1.Pages[xtraTabbedMdiManager1.Pages.Count - 1].Appearance.Header.BackColor = TabColor[(formCount - 1) % 6];
            }
        }
示例#4
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (_SelectNode == null)
            {
                return;
            }

            if (CheckProgExist())
            {
                MsgBox.Warning("程序已经存在,请勿重复添加!!!");
                return;
            }
            if (string.IsNullOrEmpty(this.textBox4.Text.Trim()))
            {
                MsgBox.Warning("程序描述不能为空!!!");
                return;
            }
            ProgList _ProgList = new ProgList();

            _ProgList.Prog_Id       = StringUnitity.GetNewGUID();
            _ProgList.Prog_Assmbly  = this.textBox1.Text.Trim();
            _ProgList.Prog_CLS      = this.textBox3.Text.Trim();
            _ProgList.Prog_Descp    = this.textBox4.Text.Trim();
            _ProgList.Prog_NameSp   = this.textBox2.Text.Trim();
            _ProgList.Prog_ParantId = _SelectNode.Prog_Id;
            if (this.checkEdit1.Checked)
            {
                _ProgList.Prog_Status = 1;
            }
            else
            {
                _ProgList.Prog_Status = 9;
            }
            _ProgList.Prog_Type = "Application";
            try
            {
                _CoreProgList.AddEntity(_ProgList);

                MsgBox.Infor("程序新增完成");
                _LoadTree.CreateTree(this.advTree1);
            }
            catch (Exception ex)
            {
                MsgBox.Warning("程序新增失败:" + ex.Message);
            }
        }
示例#5
0
 private void advTree1_NodeMouseUp(object sender, DevComponents.AdvTree.TreeNodeMouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         _SelectNode        = null;
         _SelectAdvNode     = null;
         _SelectAdvNode     = e.Node;
         _SelectNode        = e.Node.Tag as ProgList;
         this.textBox5.Text = _SelectNode.Prog_Id;
         this.textBox6.Text = _SelectNode.Prog_Descp;
     }
     else
     {
         _SelectNode        = null;
         _SelectAdvNode     = null;
         _SelectAdvNode     = e.Node;
         _SelectNode        = e.Node.Tag as ProgList;
         this.textBox5.Text = _SelectNode.Prog_Id;
         this.textBox6.Text = _SelectNode.Prog_Descp;
         popupMenu1.ShowPopup(MousePosition);
     }
 }
示例#6
0
 private void AddProgram_Load(object sender, EventArgs e)
 {
     _LoadTree.CreateTree(this.advTree1);
     _SelectNode    = null;
     _SelectAdvNode = null;
 }
示例#7
0
        private static int Start(string progName)
        {
            var trayIcon = new NotifyIcon {
                Icon = GUI.Properties.Resources.icon
            };
            var  progs = new ProgList();
            Prog prog;

            try
            {
                int progId = Int32.Parse(progName);
                prog = progs.Get(progId);
            }
            catch (FormatException)
            {
                prog = progs.Get(progName);
            }

            if (prog == null || !prog.IsOK() || (prog.DiskImage.Length > 0 && !prog.DiskImageOK()))
            {
                ShowError(String.Format(Localization.Strings.ProgNotFound, progName));
                return(-1);
            }

            var info = new InfoWindow(String.Format(Localization.Strings.ProgPreparing, prog.Name));

            info.Show();

            trayIcon.Text = String.Format(Localization.Strings.ProgWaitingEnd, prog.Name);

            VirtualDrive virtualDrive = null;

            if (prog.DiskImage.Length > 0)
            {
                if (!new MainWindow().findDT())
                {
                    return(-1);
                }

                var opts = new Options();
                if (!opts.Reload())
                {
                    ShowError(Localization.Strings.OptionsError);
                    return(-1);
                }
                virtualDrive = opts.VirtualDrive;

                if (!virtualDrive.IsValid)
                {
                    info.Close();
                    ShowError(Localization.Strings.InvalidDrive + " : " + virtualDrive);
                    return(-1);
                }

                info.Close();
                info = new InfoWindow(String.Format(Localization.Strings.DiskImageMounting, prog.DiskImage, prog.Name));
                info.Show();
                if (!prog.MountDiskImage(virtualDrive))
                {
                    ShowError(Localization.Strings.ErrorMounting);
                    return(-1);
                }
            }

            info.Close();
            info = new InfoWindow(String.Format(Localization.Strings.ProgStarting, prog.Name));
            info.Show();

            Process proc = prog.Start();

            trayIcon.Visible = true;
            info.Close();
            proc.WaitForExit();
            trayIcon.Visible = false;

            if (virtualDrive != null && virtualDrive.IsValid)
            {
                info = new InfoWindow(Localization.Strings.DiskImageUnmounting);
                info.Show();
                virtualDrive.Umount();
                info.Close();
            }
            return(0);
        }