Пример #1
0
        void ToolButton_Click(ToolButton_VM tb, object sender)
        {
            if (!_listToolStripItem.ContainsKey(tb))
            {
                return;
            }
            var propertyCall = _listToolStripItem[tb];

            try
            {
                // create the ProcessStartInfo using "cmd" as the program to be run,
                // and "/c " as the parameters.
                // Incidentally, /c tells cmd that we want it to execute the command that follows,
                // and then exit.
                var procStartInfo = new ProcessStartInfo(propertyCall.File, propertyCall.Params);
                var proc          = new Process
                {
                    StartInfo = procStartInfo
                };
                proc.Start();
            }
            catch (Exception ex)
            {
                // Ошибка при запуске приложения. Возможный выход - попросить пользователя самому запустить
                MessageBox.Show("Ошибка при запуске! Ошибка: " + ex.Message);
            }
        }
Пример #2
0
        private void AddConrolPanelTools(ICollection <PropertyCall> listPropertyCall)
        {
            if (listPropertyCall == null)
            {
                return;
            }
            var toolBar = Program.BManager.FindToolBar("TbFastStart");

            toolBar.ListButton.Clear();
            _listToolStripItem.Clear();
            foreach (var item in listPropertyCall.Reverse())
            {
                Icon          icon   = IconModule.GetIcon(item.Icon, item.File);
                ToolButton_VM button = new ToolButton_VM(toolBar, item.Title, ToolButton_Click);
                button.Image = (icon != null)
                            ? icon.ToBitmap()
                            : null;
                toolBar.ListButton.Add(button);
                _listToolStripItem.Add(button, item);
            }
        }