Inheritance: System.ComponentModel.Component, INotifyPropertyChanged
コード例 #1
0
        /// <summary>
        /// Show a task dialog using the specified values as content.
        /// </summary>
        /// <param name="windowTitle">Caption of the window.</param>
        /// <param name="mainInstruction">Principal text.</param>
        /// <param name="content">Extra text.</param>
        /// <param name="icon">Predefined icon.</param>
        /// <param name="commonButtons">Common buttons.</param>
        /// <returns>One of the DialogResult values.</returns>
        public static DialogResult Show(string windowTitle,
                                        string mainInstruction,
                                        string content,
                                        MessageBoxIcon icon,
                                        TaskDialogButtons commonButtons)
        {
            // Create a temporary task dialog for storing definition whilst showing
            using (KryptonTaskDialog taskDialog = new KryptonTaskDialog())
            {
                // Store incoming values
                taskDialog.WindowTitle     = windowTitle;
                taskDialog.MainInstruction = mainInstruction;
                taskDialog.Content         = content;
                taskDialog.Icon            = icon;
                taskDialog.CommonButtons   = commonButtons;

                // Show as a modal dialog
                return(taskDialog.ShowDialog());
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: qiancy/HaiFengTerminal
 bool Confirm(string pKey, string pMsg)
 {
     if (((ToolStripMenuItem)this.ToolStripMenuItemOption.DropDownItems[pKey]).Checked)
     {
         KryptonTaskDialog dialog = new KryptonTaskDialog
         {
             CheckboxText = @"以后不再确认",
             CheckboxState = false,
             WindowTitle = @"确认",
             MainInstruction = string.Format("{0}\t", pMsg),//不加\t中文显示缺最后一个字
             Icon = MessageBoxIcon.Question,
             CommonButtons = TaskDialogButtons.OK | TaskDialogButtons.Cancel
         };
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             ((ToolStripMenuItem)this.ToolStripMenuItemOption.DropDownItems[pKey]).Checked = dialog.CheckboxState == false;
             return true;
         }
         return false;
     }
     return true;
 }
コード例 #3
0
        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_taskDialog != null)
                    _taskDialog = null;
            }

            base.Dispose(disposing);
        }
コード例 #4
0
        /// <summary>
        /// Initialize a new instance of the VisualTaskDialog class.
        /// </summary>
        /// <param name="taskDialog">Reference to component with definition of content.</param>
        public VisualTaskDialog(KryptonTaskDialog taskDialog)
        {
            // Must provide a valid reference
            if (taskDialog == null)
                throw new ArgumentNullException("taskDialog");

            _taskDialog = taskDialog;

            // Initialize with task dialog values
            _windowTitle = taskDialog.WindowTitle;
            _mainInstruction = taskDialog.MainInstruction;
            _content = taskDialog.Content;
            _mainIcon = taskDialog.Icon;
            _customMainIcon = taskDialog.CustomIcon;
            _radioButtons = taskDialog.RadioButtons;
            _commandButtons = taskDialog.CommandButtons;
            _commonButtons = taskDialog.CommonButtons;
            _defaultRadioButton = taskDialog.DefaultRadioButton;
            _defaultButton = taskDialog.DefaultButton;
            _footerIcon = taskDialog.FooterIcon;
            _customFooterIcon = taskDialog.CustomFooterIcon;
            _footerText = taskDialog.FooterText;
            _footerHyperlink = taskDialog.FooterHyperlink;
            _checkboxText = taskDialog.CheckboxText;
            _checkboxState = taskDialog.CheckboxState;
            _allowDialogClose = taskDialog.AllowDialogClose;

            InitializeComponent();
            UpdateContents();
        }
コード例 #5
0
        /// <summary>
        /// Show a task dialog using the specified values as content.
        /// </summary>
        /// <param name="windowTitle">Caption of the window.</param>
        /// <param name="mainInstruction">Principal text.</param>
        /// <param name="content">Extra text.</param>
        /// <param name="icon">Predefined icon.</param>
        /// <param name="commonButtons">Common buttons.</param>
        /// <returns>One of the DialogResult values.</returns>
        public static DialogResult Show(string windowTitle,
                                        string mainInstruction,
                                        string content,
                                        MessageBoxIcon icon,
                                        TaskDialogButtons commonButtons)
        {
            // Create a temporary task dialog for storing definition whilst showing
            using (KryptonTaskDialog taskDialog = new KryptonTaskDialog())
            {
                // Store incoming values
                taskDialog.WindowTitle = windowTitle;
                taskDialog.MainInstruction = mainInstruction;
                taskDialog.Content = content;
                taskDialog.Icon = icon;
                taskDialog.CommonButtons = commonButtons;

                // Show as a modal dialog
                return taskDialog.ShowDialog();
            }
        }
コード例 #6
0
        private string CheckFileExists(string filename)
        {
            if (File.Exists(filename))
                return filename;

            if (_textData.IsOpened && Path.GetFileName(_textData.Filename) == Path.GetFileName(filename))
                return filename;

            string baseDir = Utilities.GetAbsolutePath(Properties.Settings.Default.ScriptPath);

            var files = Directory.GetFiles(baseDir, Path.GetFileName(filename), SearchOption.AllDirectories);
            if (files.Length == 0)
                return null;

            var ktd = new KryptonTaskDialog
            {
                Icon = MessageBoxIcon.Information,
                CommonButtons = TaskDialogButtons.Cancel,
                WindowTitle = "����ȥ����浵�м�¼��·����Ϣ��̫��ȷ",
                MainInstruction = "��������������ļ���������ȷ�ġ���",
                Content = Utilities.GetRelativePath(files[0], Utilities.GetAbsolutePath("")),
            };

            var ktdcOk = new KryptonTaskDialogCommand
            {
                DialogResult = DialogResult.OK,
                Image = Properties.Resources.arrow_right_green,
                Text = "��������",
            };
            var ktdcNo = new KryptonTaskDialogCommand
            {
                DialogResult = DialogResult.Cancel,
                Image = Properties.Resources.arrow_right_red,
                Text = "��������Ǵ����",
            };

            ktd.CommandButtons.AddRange(new[] { ktdcOk, ktdcNo });
            if (ktd.ShowDialog() == DialogResult.OK)
                return files[0];

            return null;
        }