ui相关工具类 作者:于小懒
Exemplo n.º 1
0
 private void OnBtnActionMoveUp(object sender, EventArgs e)
 {
     UIUtil.MoveSelectedItemsInternalOne(m_lvActions,
                                         m_trigger.ActionCollection, true);
     UpdateActionListEx(true);
 }
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_modMod">The mod for which the script is running.</param>
		/// <param name="p_gmdGameMode">The game mode currently being managed.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_igpInstallers">The utility class to use to install the mod items.</param>
		/// <param name="p_uipUIProxy">The UI manager to use to interact with UI elements.</param>
		public CSharpScriptFunctionProxy(IMod p_modMod, IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, InstallerGroup p_igpInstallers, UIUtil p_uipUIProxy)
			: base(p_modMod, p_gmdGameMode, p_eifEnvironmentInfo, p_igpInstallers, p_uipUIProxy)
		{
		}
Exemplo n.º 3
0
 private void OnBtnEventMoveDown(object sender, EventArgs e)
 {
     UIUtil.MoveSelectedItemsInternalOne(m_lvEvents,
                                         m_trigger.EventCollection, false);
     UpdateEventListEx(true);
 }
Exemplo n.º 4
0
 private void OnBtnConditionMoveDown(object sender, EventArgs e)
 {
     UIUtil.MoveSelectedItemsInternalOne(m_lvConditions,
                                         m_trigger.ConditionCollection, false);
     UpdateConditionListEx(true);
 }
Exemplo n.º 5
0
 private void OnEventDelete(object sender, EventArgs e)
 {
     UIUtil.DeleteSelectedItems(m_lvEvents, m_trigger.EventCollection);
 }
Exemplo n.º 6
0
 private void OnActionDelete(object sender, EventArgs e)
 {
     UIUtil.DeleteSelectedItems(m_lvActions, m_trigger.ActionCollection);
 }
Exemplo n.º 7
0
    public void MordredCheck()
    {
        //reset input if u change ur mind
        if (Input.GetKeyDown(KeyCode.Q))
        {
            mordCurr = 0;
            Debug.Log("Reset Mordred Input");
            return;
        }

        //shift and then numbers
        if (Input.GetKey(KeyCode.LeftShift))
        {
            if (mordCurr < 3)
            {
                if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Keypad1))
                {
                    mordredControllerBeta[mordCurr] = 0;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Keypad2))
                {
                    mordredControllerBeta[mordCurr] = 1;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Keypad3))
                {
                    mordredControllerBeta[mordCurr] = 2;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha4) || Input.GetKeyDown(KeyCode.Keypad4))
                {
                    mordredControllerBeta[mordCurr] = 3;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha5) || Input.GetKeyDown(KeyCode.Keypad5))
                {
                    mordredControllerBeta[mordCurr] = 4;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha6) || Input.GetKeyDown(KeyCode.Keypad6))
                {
                    mordredControllerBeta[mordCurr] = 5;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha7) || Input.GetKeyDown(KeyCode.Keypad7))
                {
                    mordredControllerBeta[mordCurr] = 6;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha8) || Input.GetKeyDown(KeyCode.Keypad8))
                {
                    mordredControllerBeta[mordCurr] = 7;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha9) || Input.GetKeyDown(KeyCode.Keypad9))
                {
                    mordredControllerBeta[mordCurr] = 8;
                    mordCurr++;
                }
                else if (Input.GetKeyDown(KeyCode.Alpha0) || Input.GetKeyDown(KeyCode.Keypad0))
                {
                    mordredControllerBeta[mordCurr] = 9;
                    mordCurr++;
                }
            }


            if (mordCurr >= mordredControllerBeta.Length)
            {
                Debug.Log("Player " + (mordredControllerBeta[0] + 1).ToString() + " Casting Mordred on Player " +
                          (mordredControllerBeta[1] + 1).ToString() + "'s Ally number " + (mordredControllerBeta[2] + 1).ToString());
                if (mordredControllerBeta[0] < numPlayers && mordredControllerBeta[1] < numPlayers)
                {
                    if (players[mordredControllerBeta[1]].activeAllies.Count > mordredControllerBeta[2])
                    {
                        for (int i = 0; i < players[mordredControllerBeta[0]].hand.Count; i++)
                        {
                            if (players[mordredControllerBeta[0]].hand[i].name == "Mordred")
                            {
                                List <Card> tempCards = new List <Card>();

                                tempCards.Add(players[mordredControllerBeta[0]].hand[i]);
                                tempCards.Add(players[mordredControllerBeta[1]].activeAllies[mordredControllerBeta[2]]);

                                players[mordredControllerBeta[0]].hand.RemoveAt(i);
                                players[mordredControllerBeta[1]].activeAllies.RemoveAt(mordredControllerBeta[2]);

                                GameUtil.DiscardCards(adventureDeck, tempCards, adventureDeckDiscardPileUIButton);
                            }
                        }
                        UIUtil.PopulatePlayerBoard(this);
                    }
                }
                mordCurr = 0;
            }
        }
    }
        /// <summary>
        /// Used to modify other form when they load.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WindowAddedHandler(object sender, GwmWindowEventArgs e)
        {
            var keyPromptForm = e.Form as KeyPromptForm;

            if (keyPromptForm != null)
            {
                keyPromptForm.Shown += delegate(object sender2, EventArgs e2)
                {
                    // Warning: If one of the private fields get renamed this method will fail!
                    var m_cmbKeyFile = keyPromptForm.Controls.Find("m_cmbKeyFile", false).FirstOrDefault() as ComboBox;
                    if (m_cmbKeyFile != null)
                    {
                        var fieldInfo = keyPromptForm.GetType().GetField("m_ioInfo", BindingFlags.Instance | BindingFlags.NonPublic);
                        if (fieldInfo != null)
                        {
                            var ioInfo = fieldInfo.GetValue(keyPromptForm) as IOConnectionInfo;
                            if (ioInfo != null)
                            {
                                if (provider.IsCachedKey(ioInfo.Path))
                                {
                                    var index = m_cmbKeyFile.Items.IndexOf(ShortProductName);
                                    if (index != -1)
                                    {
                                        m_cmbKeyFile.SelectedIndex = index;

                                        var m_cbPassword = keyPromptForm.Controls.Find("m_cbPassword", false).FirstOrDefault() as CheckBox;
                                        if (m_cbPassword != null)
                                        {
                                            UIUtil.SetChecked(m_cbPassword, false);
                                        }

                                        // If AutoPrompt is enabled click the Ok button.
                                        if (Host.CustomConfig.GetBool(QuickUnlockProvider.CfgAutoPrompt, true))
                                        {
                                            var m_btnOK = keyPromptForm.Controls.Find("m_btnOK", false).FirstOrDefault() as Button;
                                            if (m_btnOK != null)
                                            {
                                                m_btnOK.PerformClick();
                                            }
                                        }

                                        return;
                                    }
                                }
                            }
                        }

                        // If KeePass autoselected QuickUnlock but there isn't a key available just unselect it.
                        if (m_cmbKeyFile.Text == ShortProductName)
                        {
                            var m_cbKeyFile = keyPromptForm.Controls.Find("m_cbKeyFile", false).FirstOrDefault() as CheckBox;
                            if (m_cbKeyFile != null)
                            {
                                UIUtil.SetChecked(m_cbKeyFile, false);
                            }
                        }
                    }
                };
            }

            var optionsForm = e.Form as OptionsForm;

            if (optionsForm != null)
            {
                optionsForm.Shown += delegate(object sender2, EventArgs e2)
                {
                    try
                    {
                        // Add the QuickUnlock options tab.
                        var m_tabMain = optionsForm.Controls.Find("m_tabMain", true).FirstOrDefault() as TabControl;
                        if (m_tabMain != null)
                        {
                            if (m_tabMain.ImageList == null)
                            {
                                m_tabMain.ImageList = new ImageList();
                            }
                            var imageIndex = m_tabMain.ImageList.Images.Add(Properties.Resources.B16x16_TimeLock, Color.Transparent);

                            var newTab = new TabPage(ShortProductName);
                            newTab.UseVisualStyleBackColor = true;
                            newTab.ImageIndex = imageIndex;

                            var optionsPanel = new OptionsPanel(this);
                            newTab.Controls.Add(optionsPanel);
                            optionsPanel.Dock = DockStyle.Fill;

                            m_tabMain.TabPages.Add(newTab);
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.Fail(ex.ToString());
                    }
                };
            }
        }
Exemplo n.º 9
0
        private void GetObjectPropsUnscaled(string strPath, DriveInfo drvHint,
                                            out Image img, ref string strDisplayName)
        {
            img = null;

            try
            {
                string strName;
                NativeMethods.SHGetFileInfo(strPath, m_nIconDim, out img,
                                            out strName);

                if (!string.IsNullOrEmpty(strName) && (strName.IndexOf(
                                                           Path.DirectorySeparatorChar) < 0))
                {
                    strDisplayName = strName;
                }

                if (img != null)
                {
                    return;
                }
            }
            catch (Exception) { Debug.Assert(false); }

            ImageList.ImageCollection icons = Program.MainForm.ClientIcons.Images;

            if ((strPath.Length <= 3) && (drvHint != null))
            {
                switch (drvHint.DriveType)
                {
                case DriveType.Fixed:
                    img = new Bitmap(icons[(int)PwIcon.Drive]);
                    break;

                case DriveType.CDRom:
                    img = new Bitmap(icons[(int)PwIcon.CDRom]);
                    break;

                case DriveType.Network:
                    img = new Bitmap(icons[(int)PwIcon.NetworkServer]);
                    break;

                case DriveType.Ram:
                    img = new Bitmap(icons[(int)PwIcon.Memory]);
                    break;

                case DriveType.Removable:
                    img = new Bitmap(icons[(int)PwIcon.Disk]);
                    break;

                default:
                    img = new Bitmap(icons[(int)PwIcon.Folder]);
                    break;
                }

                return;
            }

            img = UIUtil.GetFileIcon(strPath, m_nIconDim, m_nIconDim);
            if (img != null)
            {
                return;
            }

            if (Directory.Exists(strPath))
            {
                img = new Bitmap(icons[(int)PwIcon.Folder]);
                return;
            }
            if (File.Exists(strPath))
            {
                img = new Bitmap(icons[(int)PwIcon.PaperNew]);
                return;
            }

            Debug.Assert(false);
            img = new Bitmap(icons[(int)PwIcon.Star]);
        }
Exemplo n.º 10
0
 public ExceptionDialog()
 {
     base.SuspendLayout();
     this.toolTip                        = new ToolTip();
     base.Icon                           = PdnInfo.AppIcon;
     this.errorIconBox                   = new PictureBox();
     this.errorIconBox.SizeMode          = PictureBoxSizeMode.StretchImage;
     this.errorIconBox.Image             = this.GetScaledWarningIcon();
     this.messageLabel                   = new PdnLabel();
     this.message2Label                  = new PdnLabel();
     this.bottomSeparator                = new PaintDotNet.Controls.SeparatorLine();
     this.detailsButton                  = new PdnPushButton();
     this.detailsButton.Click           += new EventHandler(this.OnDetailsButtonClick);
     this.detailsButton.AutoSize         = true;
     this.button1                        = new PdnPushButton();
     this.button1.AutoSize               = true;
     this.button1.DialogResult           = DialogResult.OK;
     this.button1.Visible                = false;
     this.button2                        = new PdnPushButton();
     this.button2.Text                   = PdnResources.GetString("Form.OkButton.Text");
     this.button2.AutoSize               = true;
     this.button2.DialogResult           = DialogResult.Cancel;
     this.copyToClipboardButton          = new PdnPushButton();
     this.copyToClipboardButton.Text     = PdnResources.GetString("ExceptionDialog.CopyToClipboardButton.Text");
     this.copyToClipboardButton.AutoSize = true;
     this.copyToClipboardButton.Click   += new EventHandler(this.OnCopyToClipboardButtonClick);
     this.folderIconBox                  = new PictureBox();
     this.folderIconBox.SizeMode         = PictureBoxSizeMode.StretchImage;
     this.folderIconBox.Image            = PdnResources.GetImageResource("Icons.FolderShortcut.png").Reference;
     this.folderIconBox.Visible          = false;
     this.openFolderLink                 = new PdnLinkLabel();
     this.openFolderLink.Text            = PdnResources.GetString("ExceptionDialog.OpenFolderLink.Text");
     this.openFolderLink.LinkClicked    += new LinkLabelLinkClickedEventHandler(this.OnOpenFolderLinkLinkClicked);
     this.openFolderLink.Visible         = false;
     this.openFolderLink.AutoSize        = true;
     this.crashLogTextBox                = new TextBox();
     this.crashLogTextBox.Multiline      = true;
     this.crashLogTextBox.ReadOnly       = true;
     this.crashLogTextBox.ScrollBars     = ScrollBars.Vertical;
     this.crashLogTextBox.Font           = new Font(FontFamily.GenericMonospace, this.crashLogTextBox.Font.Size);
     this.crashLogTextBox.Visible        = false;
     this.crashLogTextBox.KeyPress      += new KeyPressEventHandler(this.OnCrashLogTextBoxKeyPress);
     this.detailsButton.Text             = this.GetDetailsButtonText();
     this.detailsButton.TabIndex         = 0;
     this.button1.TabIndex               = 1;
     this.button2.TabIndex               = 2;
     this.copyToClipboardButton.TabIndex = 3;
     this.openFolderLink.TabIndex        = 4;
     this.crashLogTextBox.TabIndex       = 5;
     base.Controls.Add(this.errorIconBox);
     base.Controls.Add(this.messageLabel);
     base.Controls.Add(this.message2Label);
     base.Controls.Add(this.bottomSeparator);
     base.Controls.Add(this.detailsButton);
     base.Controls.Add(this.button2);
     base.Controls.Add(this.button1);
     base.Controls.Add(this.copyToClipboardButton);
     base.Controls.Add(this.folderIconBox);
     base.Controls.Add(this.openFolderLink);
     base.Controls.Add(this.crashLogTextBox);
     this.Text            = PdnInfo.BareProductName;
     this.BackColor       = SystemColors.Window;
     base.FormBorderStyle = FormBorderStyle.Sizable;
     base.MaximizeBox     = false;
     base.MinimizeBox     = false;
     base.AcceptButton    = this.button1;
     base.CancelButton    = this.button2;
     base.ClientSize      = new Size(UIUtil.ScaleWidth(450), base.ClientSize.Height);
     base.StartPosition   = FormStartPosition.CenterScreen;
     this.DoubleBuffered  = true;
     base.ShowInTaskbar   = false;
     base.ResumeLayout(false);
     base.PerformLayout();
     this.MinimumSize = base.Size;
     this.button1.Focus();
 }
Exemplo n.º 11
0
        protected override void OnLayout(LayoutEventArgs levent)
        {
            int  num15;
            int  num16;
            int  y    = UIUtil.ScaleWidth(8);
            int  x    = UIUtil.ScaleHeight(8);
            Size size = UIUtil.ScaleSize(0x55, 0x18);

            this.errorIconBox.Location = new Point(x, y);
            this.errorIconBox.Size     = this.errorIconBox.Image.Size;
            this.errorIconBox.PerformLayout();
            this.messageLabel.Location = new Point(this.errorIconBox.Right + x, this.errorIconBox.Top);
            this.messageLabel.Width    = (base.ClientSize.Width - this.messageLabel.Left) - x;
            this.messageLabel.Height   = this.messageLabel.GetPreferredSize(new Size(this.messageLabel.Width, 1)).Height;
            bool flag = !string.IsNullOrWhiteSpace(this.message2Label.Text);

            this.message2Label.Location = new Point(this.messageLabel.Left, this.messageLabel.Bottom + (flag ? y : 0));
            this.message2Label.Width    = (base.ClientSize.Width - this.message2Label.Left) - x;
            this.message2Label.Height   = flag ? this.message2Label.GetPreferredSize(new Size(this.message2Label.Width, 1)).Height : 0;
            int num3 = y + Math.Max(this.errorIconBox.Bottom, this.message2Label.Bottom);

            this.bottomSeparator.Location = new Point(x, num3);
            int width = base.ClientSize.Width - (2 * x);

            this.bottomSeparator.Width = width;
            this.bottomSeparator.Size  = this.bottomSeparator.GetPreferredSize(new Size(width, 1));
            this.button2.Size          = size;
            this.button2.PerformLayout();
            int num5 = this.bottomSeparator.Bottom + y;

            this.button2.Location = new Point((base.ClientSize.Width - x) - this.button2.Width, num5);
            int num6 = this.bottomSeparator.Bottom + y;

            this.button1.Size = size;
            this.button1.PerformLayout();
            int top = this.button2.Top;

            this.button1.Location   = new Point((this.button2.Left - x) - this.button1.Width, top);
            this.detailsButton.Size = size;
            this.detailsButton.PerformLayout();
            int num8 = this.bottomSeparator.Bottom + y;

            this.detailsButton.Location = new Point(x, num8);
            int num9 = y + Int32Util.Max(this.detailsButton.Bottom, this.button2.Bottom, this.button1.Bottom);

            this.copyToClipboardButton.Location = new Point(x, num9);
            this.copyToClipboardButton.Size     = size;
            this.copyToClipboardButton.PerformLayout();
            this.copyToClipboardButton.Size = this.copyToClipboardButton.GetPreferredSize(this.copyToClipboardButton.Size);
            this.folderIconBox.Size         = UIUtil.ScaleSize(this.folderIconBox.Image.Size);
            this.folderIconBox.Location     = new Point(this.copyToClipboardButton.Right + x, this.copyToClipboardButton.Top + ((this.copyToClipboardButton.Height - this.folderIconBox.Height) / 2));
            this.openFolderLink.Size        = this.openFolderLink.GetPreferredSize(new Size(1, 1));
            this.openFolderLink.Location    = new Point(this.folderIconBox.Right + (x / 2), this.folderIconBox.Top + ((this.folderIconBox.Height - this.openFolderLink.Height) / 2));
            int num10 = UIUtil.ScaleHeight(250);

            if (this.crashLogTextBox.Visible)
            {
                int num19 = y + Int32Util.Max(this.copyToClipboardButton.Bottom, this.folderIconBox.Bottom, this.openFolderLink.Bottom);
                this.crashLogTextBox.Location = new Point(x, num19);
                this.crashLogTextBox.Width    = base.ClientSize.Width - (2 * x);
                int num20 = (base.ClientSize.Height - y) - this.crashLogTextBox.Top;
                this.crashLogTextBox.Height = Math.Max(num10, num20);
            }
            int num11 = y + Int32Util.Max(this.detailsButton.Bottom, this.button1.Bottom, this.button2.Bottom, this.crashLogTextBox.Visible ? this.crashLogTextBox.Bottom : 0);
            int num12 = (((x + (this.detailsButton.Visible ? (this.detailsButton.Width + x) : 0)) + (this.button1.Visible ? (this.button1.Width + x) : 0)) + this.button2.Width) + x;
            int num13 = (x + (this.copyToClipboardButton.Visible ? (this.copyToClipboardButton.Width + x) : 0)) + (this.openFolderLink.Visible ? (this.openFolderLink.Width + x) : 0);
            int num14 = Math.Max(num12, num13);

            if (this.crashLogTextBox.Visible)
            {
                num15 = (num11 - this.crashLogTextBox.Height) + num10;
                num16 = 0x7d0;
            }
            else
            {
                num15 = num11;
                num16 = num11;
            }
            int[] vals   = new int[] { base.ClientSize.Width };
            int   num17  = Int32Util.Max(num14, vals);
            int   height = Int32Util.Clamp(base.ClientSize.Height, num15, num16);

            base.ClientSize    = new Size(num17, height);
            this.minClientSize = new Size(num14, num15);
            this.maxClientSize = new Size(0x7d0, num16);
            base.OnLayout(levent);
        }
Exemplo n.º 12
0
 private void ProcessResize()
 {
     UIUtil.ResizeColumns(m_lvMessages, true);
 }
Exemplo n.º 13
0
        private void OnClickKeyFileCreate(object sender, EventArgs e)
        {
            SaveFileDialogEx sfd = UIUtil.CreateSaveFileDialog(KPRes.KeyFileCreate,
                                                               UrlUtil.StripExtension(UrlUtil.GetFileName(m_ioInfo.Path)) + "." +
                                                               AppDefs.FileExtension.KeyFile, UIUtil.CreateFileTypeFilter("key",
                                                                                                                          KPRes.KeyFiles, true), 1, "key", AppDefs.FileDialogContext.KeyFile);

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                EntropyForm dlg = new EntropyForm();
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    byte[] pbAdditionalEntropy = dlg.GeneratedEntropy;

                    try
                    {
                        KcpKeyFile.Create(sfd.FileName, pbAdditionalEntropy);

                        string str = sfd.FileName;
                        m_cmbKeyFile.Items.Add(str);
                        m_cmbKeyFile.SelectedIndex = m_cmbKeyFile.Items.Count - 1;
                    }
                    catch (Exception exKC)
                    {
                        MessageService.ShowWarning(exKC);
                    }
                }
                UIUtil.DestroyForm(dlg);
            }

            EnableUserControls();
        }