当前位置: 首页>>代码示例>>C#>>正文


C# Label.GetPreferredSize方法代码示例

本文整理汇总了C#中System.Windows.Forms.Label.GetPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C# Label.GetPreferredSize方法的具体用法?C# Label.GetPreferredSize怎么用?C# Label.GetPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Label的用法示例。


在下文中一共展示了Label.GetPreferredSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: lbReports_SelectedIndexChanged

        private void lbReports_SelectedIndexChanged(object sender, EventArgs e)
        {
            panelReportParameters.Controls.Clear();
            if (lbReports.SelectedItem != null)
            {
                Reports.ReportEntry entry = lbReports.SelectedItem as Reports.ReportEntry;
                entry.DefaultsHandler(entry.ReportParameters);

                panelReportParameters.Visible = false;
                Label description = new Label();
                if (entry.ReportParameters != null)
                {
                    panelReportParameters.Controls.Add(entry.ReportParameters);
                }
                panelReportParameters.Controls.Add(description);
                description.Text = entry.Description;
                description.Dock = DockStyle.Top;
                description.Padding = new Padding(0, 0, 0, 6);
                //description.AutoSize = true;
                description.Size = description.GetPreferredSize(description.Size);
                panelReportParameters.Visible = true;
                btnRunReport.Enabled = true;
            }
            else
            {
                btnRunReport.Enabled = false;
            }
        }
开发者ID:e-Deniska,项目名称:easyMoney,代码行数:28,代码来源:ReportListForm.cs

示例2: MenuFileViewPluginLoadErrors_Click

        private void MenuFileViewPluginLoadErrors_Click(object sender, EventArgs e)
        {
            IList<Triple<Assembly, Type, Exception>> allErrors = AppWorkspace.GetEffectLoadErrors();
            IList<Triple<Assembly, Type, Exception>> errors = RemoveDuplicates(allErrors);

            using (Form errorsDialog = new Form())
            {
                errorsDialog.Icon = Utility.ImageToIcon(PdnResources.GetImageResource("Icons.MenuFileViewPluginLoadErrorsIcon.png").Reference);
                errorsDialog.Text = PdnResources.GetString("Effects.PluginLoadErrorsDialog.Text");

                Label messageLabel = new Label();
                messageLabel.Name = "messageLabel";
                messageLabel.Text = PdnResources.GetString("Effects.PluginLoadErrorsDialog.Message.Text");

                TextBox errorsBox = new TextBox();
                errorsBox.Font = new Font(FontFamily.GenericMonospace, errorsBox.Font.Size);
                errorsBox.ReadOnly = true;
                errorsBox.Multiline = true;
                errorsBox.ScrollBars = ScrollBars.Vertical;

                StringBuilder allErrorsText = new StringBuilder();
                string headerTextFormat = PdnResources.GetString("EffectErrorMessage.HeaderFormat");

                for (int i = 0; i < errors.Count; ++i)
                {
                    Assembly assembly = errors[i].First;
                    Type type = errors[i].Second;
                    Exception exception = errors[i].Third;

                    string headerText = string.Format(headerTextFormat, i + 1, errors.Count);
                    string errorText = AppWorkspace.GetLocalizedEffectErrorMessage(assembly, type, exception);

                    allErrorsText.Append(headerText);
                    allErrorsText.Append(Environment.NewLine);
                    allErrorsText.Append(errorText);

                    if (i != errors.Count - 1)
                    {
                        allErrorsText.Append(Environment.NewLine);
                    }
                }

                errorsBox.Text = allErrorsText.ToString();

                errorsDialog.Layout +=
                    delegate(object sender2, LayoutEventArgs e2)
                    {
                        int hMargin = UI.ScaleWidth(8);
                        int vMargin = UI.ScaleHeight(8);
                        int insetWidth = errorsDialog.ClientSize.Width - (hMargin * 2);

                        messageLabel.Location = new Point(hMargin, vMargin);
                        messageLabel.Width = insetWidth;
                        messageLabel.Size = messageLabel.GetPreferredSize(new Size(messageLabel.Width, 1));

                        errorsBox.Location = new Point(hMargin, messageLabel.Bottom + vMargin);
                        errorsBox.Width = insetWidth;
                        errorsBox.Height = errorsDialog.ClientSize.Height - vMargin - errorsBox.Top;
                    };

                errorsDialog.StartPosition = FormStartPosition.CenterParent;
                errorsDialog.ShowInTaskbar = false;
                errorsDialog.MinimizeBox = false;
                errorsDialog.Width *= 2;
                errorsDialog.Size = UI.ScaleSize(errorsDialog.Size);
                errorsDialog.Controls.Add(messageLabel);
                errorsDialog.Controls.Add(errorsBox);

                errorsDialog.ShowDialog(AppWorkspace);
            }
        }
开发者ID:metadeta96,项目名称:openpdn,代码行数:71,代码来源:FileMenu.cs

示例3: AddLabelsLeftToRight

    private bool AddLabelsLeftToRight() {
      var curLoc = new Point(3, 0);
      int idx = 0;

      foreach (var bc in breadcrumbs) {
        Label label;

        if (bc == breadcrumbs.Last.Value) {
          label = new Label { Location = curLoc, AutoSize = true, Font = font, Text = bc.Item1 };
        } else {
          label = new LinkLabel { Location = curLoc, AutoSize = true, Font = font, Text = bc.Item1, Tag = bc };
          ((LinkLabel)label).LinkClicked += label_LinkClicked;
        }

        labels.Add(label);
        label.Size = label.GetPreferredSize(Size.Empty);
        curLoc.X += label.Size.Width;

        if (++idx < breadcrumbs.Count) {
          var separator = new Label { Location = curLoc, AutoSize = true, Font = font, Text = Separator };
          labels.Add(separator);
          separator.Size = separator.GetPreferredSize(Size.Empty);
          curLoc.X += separator.Size.Width;
        }
      }

      double width = Width;
      if (ViewsLabelVisible)
        width -= viewsLabel.Width + viewsLabel.Margin.Left + viewsLabel.Margin.Right;
      bool success = curLoc.X <= width;

      if (success)
        Controls.AddRange(labels.ToArray());

      return success;
    }
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:36,代码来源:BreadcrumbViewHost.cs

示例4: ReplaceMissingFiles

        /// <summary>
        /// Repairs the installation of Paint.NET by replacing any files that have gone missing.
        /// This method should only be called after it has been determined that the files are missing,
        /// and not as a way to determine which files are missing.
        /// This is used, for instance, if the resource files, such as PaintDotNet.Strings.3.resources,
        /// cannot be found. This is actually a top support issue, and by automatically repairing
        /// this problem we save a lot of people a lot of trouble.
        /// </summary>
        /// <param name="missingFiles">
        /// Friendly names for the files that are missing. These will not be used as part of the
        /// repair process but rather as part of any UI presented to the user, or in an exception that 
        /// will be thrown in the case of an error.
        /// </param>
        /// <returns>
        /// true if everything was successful, false if the user cancelled or does not have administrator
        /// privilege (and cannot elevate). An exception is thrown for errors.
        /// </returns>
        /// <remarks>
        /// Note to implementors: This may be implemented as a no-op. Just return true in this case.
        /// </remarks>
        public static bool ReplaceMissingFiles(string[] missingFiles)
        {
            // Generate a friendly, comma separated list of the missing file names
            StringBuilder missingFilesSB = new StringBuilder();

            for (int i = 0; i < missingFiles.Length; ++i)
            {
                missingFilesSB.Append(missingFiles[i]);

                if (i != missingFiles.Length - 1)
                {
                    missingFilesSB.Append(", ");
                }
            }

            try
            {
                // If they are not an admin and have no possibility of elevating, such as for a standard User
                // in XP, then give them an error. Unfortunately we do not know if we can even load text
                // resources at this point, and so must provide an English-only error message.
                if (!Security.IsAdministrator && !Security.CanElevateToAdministrator)
                {
                    MessageBox.Show(
                        null,
                        "Paint.NET has detected that some important installation files are missing. Repairing " +
                        "this requires administrator privilege. Please run the 'PdnRepair.exe' program in the installation " +
                        "directory after logging in with a user that has administrator privilege." + Environment.NewLine +
                        Environment.NewLine +
                        "The missing files are: " + missingFilesSB.ToString(),
                        "Paint.NET",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);

                    return false;
                }

                const int hMargin = 8;
                const int vMargin = 8;
                Form form = new Form();
                form.Text = "Paint.NET";
                form.ClientSize = new Size(400, 10);
                form.StartPosition = FormStartPosition.CenterScreen;

                Label infoLabel = new Label();
                form.Controls.Add(infoLabel);
                infoLabel.Text =
                    "Paint.NET has detected that some important installation files are missing. If you click " +
                    "the Repair button it will attempt to repair this and then continue loading." + Environment.NewLine +
                    Environment.NewLine +
                    "The missing files are: " + missingFilesSB.ToString();

            #if DEBUG
                infoLabel.Text += Environment.NewLine +
                    "Since this is a DEBUG build, you should probably add /skipRepairAttempt to the command-line.";
            #endif

                infoLabel.Location = new Point(hMargin, vMargin);
                infoLabel.Width = form.ClientSize.Width - hMargin * 2;
                infoLabel.Height = infoLabel.GetPreferredSize(new Size(infoLabel.Width, 1)).Height;

                Button repairButton = new Button();
                form.Controls.Add(repairButton);
                repairButton.Text = "&Repair";

                Exception exception = null;

                repairButton.Click +=
                    delegate(object sender, EventArgs e)
                    {
                        form.DialogResult = DialogResult.Yes;
                        repairButton.Enabled = false;

                        try
                        {
                            Shell.Execute(form, "PdnRepair.exe", "/noPause", false, ExecuteWaitType.WaitForExit);
                        }

                        catch (Exception ex)
                        {
                            exception = ex;
//.........这里部分代码省略.........
开发者ID:leejungho2,项目名称:xynotecgui,代码行数:101,代码来源:Shell.cs

示例5: LayoutProcessesInfo

        private void LayoutProcessesInfo()
        {
            int x = this.labelAccount.Location.X;
            const int progressDx = 20;
            int y = labelDomainExample.Location.Y + labelDomainExample.Size.Height + 6;
            Size preferredSize;
            int maxLineDx = this.Size.Width - 2 * x;
            foreach (var test in Tests)
            {
                var l = new Label();
                l.ForeColor = System.Drawing.Color.Black;
                l.AutoSize = true;
                l.Location = new System.Drawing.Point(x, y);
                l.Text = test.DisplayName;
                preferredSize = l.GetPreferredSize(new Size(maxLineDx, 13));
                l.Size = preferredSize;
                l.Show();
                test.Label = l;
                this.Controls.Add(l);
                int dy = preferredSize.Height;
                int dx = preferredSize.Width;

                var pi = new ProgressIndicator();
                pi.Location = new Point(x + dx + 4, y-3);
                pi.Size = new Size(progressDx, dy);
                test.ProgressIndicator = pi;
                this.Controls.Add(pi);
                pi.Start();

                y += (dy + 6);
            }
            FinishedCountLabel = new Label();
            FinishedCountLabel.Visible = true;
            FinishedCountLabel.Location = new Point(x, y);
            FinishedCountLabel.Text = String.Format("Finished 0 out {0} tests.", Tests.Count);
            FinishedCountLabel.Location = new Point(x, y);
            //preferredSize = FinishedCountLabel.GetPreferredSize(new Size(maxLineDx, 13));
            //FinishedCountLabel.Size = preferredSize;
            FinishedCountLabel.AutoSize = true;
            this.Controls.Add(FinishedCountLabel);

            SeeResultsLabel = new LinkLabel();
            SeeResultsLabel.Visible = false;
            SeeResultsLabel.Location = new Point(x, y);
            SeeResultsLabel.Text = "See results";
            preferredSize = SeeResultsLabel.GetPreferredSize(new Size(maxLineDx, 13));
            SeeResultsLabel.Size = preferredSize;
            SeeResultsLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(LinkLabel_Clicked);
            y += (preferredSize.Height + buttonExit.Size.Height + 30);
            this.Controls.Add(SeeResultsLabel);
            if (ClientSize.Height < y)
                ClientSize = new Size(this.ClientSize.Width, y);
        }
开发者ID:AbhinavBansal,项目名称:diagnosticapp,代码行数:53,代码来源:Form1.cs

示例6: CreateText

 private Size CreateText(int x, int y, int lineHeight, string text)
 {
     Label label = new Label();
     label.BackColor = SystemColors.Info;
     label.ForeColor = SystemColors.InfoText;
     label.Location = new Point(x, y);
     label.Text = text;
     Size clientSize = base.ClientSize;
     clientSize.Width = clientSize.Width - SystemInformation.VerticalScrollBarWidth - x;
     Size preferredSize = label.GetPreferredSize(clientSize);
     label.Size = preferredSize;
     if (lineHeight > 0)
     {
         label.Location = new Point(x, y + (lineHeight - label.Size.Height) / 2);
     }
     base.Controls.Add(label);
     return label.Size;
 }
开发者ID:Azerothian,项目名称:fc3editor,代码行数:18,代码来源:ContextHelpDock.cs


注:本文中的System.Windows.Forms.Label.GetPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。