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


C# Form.Refresh方法代码示例

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


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

示例1: ShowDialog

 public static string ShowDialog(string text, string caption, List<string> comboitems)
 {
     prompt = new Form();
     prompt.SizeChanged += new System.EventHandler(SimpleCombo_SizeChanged);
     prompt.AutoSizeMode = AutoSizeMode.GrowOnly;
     prompt.Padding = new Padding(50);
     prompt.Text = caption;
     textLabel = new Label() { Text = text, AutoSize = true};
     textLabel.Left = (int)Math.Ceiling((double)(prompt.Width - textLabel.Width) * 0.5);
     textLabel.Top = (int)Math.Ceiling((double)(prompt.Height - textLabel.Height) * 0.25);
     comboBox = new ComboBox() { DataSource = comboitems, MinimumSize = new System.Drawing.Size(500,20)};
     comboBox.Left = (int)Math.Ceiling((double)(prompt.Width - comboBox.Width) * 0.5);
     comboBox.Top = (int)Math.Ceiling((double)(prompt.Height - comboBox.Height) * 0.5);
     confirmation = new Button() {Text = "OK" };
     confirmation.Left = (int)Math.Ceiling((double)(prompt.Width - confirmation.Width) * 0.5);
     confirmation.Top = (int)Math.Ceiling((double)(prompt.Height - confirmation.Height) * 0.75);
     confirmation.Click += (sender, e) => { prompt.Close(); };
     prompt.Controls.Add(confirmation);
     prompt.Controls.Add(textLabel);
     prompt.Controls.Add(comboBox);
     prompt.AcceptButton = confirmation;
     prompt.AutoSize = true;
     prompt.Refresh();
     prompt.ShowDialog();
     return comboBox.SelectedItem.ToString();
 }
开发者ID:Merp,项目名称:SharpTune,代码行数:26,代码来源:SimpleCombo.cs

示例2: setPermission

 /// <summary>
 /// 
 /// </summary>
 /// <param name="mainForm"></param>
 /// <param name="clientInfo"></param>
 public static void setPermission(Form mainForm,ClientInfo clientInfo)
 {
     MenuStrip mainMenu = mainForm.MainMenuStrip;
     setPermission(clientInfo.LoggedUser, ref mainMenu, clientInfo.MenuPermissions);
     mainForm.Invalidate();
     mainForm.Refresh();
     mainMenu.Refresh();
 }
开发者ID:DelLitt,项目名称:opmscoral,代码行数:13,代码来源:MenuUtility.cs

示例3: FadeIn

 public static void FadeIn(Form frm)
 {
     float FadeIn;
     for (FadeIn = 0.0f; FadeIn <= 1.1; FadeIn += 0.1f)
     {
         frm.Opacity = FadeIn;
         frm.Refresh();
         System.Threading.Thread.Sleep(100);
     }
 }
开发者ID:arashrasoulzadeh,项目名称:.netPLUS,代码行数:10,代码来源:GUI.cs

示例4: FadeOut

 public static void FadeOut(Form frm)
 {
     float FadeOut;
     for (FadeOut = 90; FadeOut >= 10; FadeOut += -10)
     {
         frm.Opacity = FadeOut / 100;
         frm.Refresh();
         System.Threading.Thread.Sleep(100);
     }
 }
开发者ID:arashrasoulzadeh,项目名称:.netPLUS,代码行数:10,代码来源:GUI.cs

示例5: AttachForm

        public static void AttachForm(Form form)
        {
            Action<string> handler = msg => form.BeginInvoke((Action)(() =>
            {
                form.Text = msg;
                form.Refresh();
            }));

            MessageSanded += handler;
            form.Closed += (s, e) => MessageSanded -= handler;
        }
开发者ID:poolsar,项目名称:LotCreator,代码行数:11,代码来源:ProccessMesenger.cs

示例6: FadeOut

        public void FadeOut(Form TargetForm, double FadeStep)
        {
            if (TargetForm.Visible == false)
            {
                return;
            }

            for (_i = 1; _i >= _MinOpacity; _i -= FadeStep)
            {
                TargetForm.Opacity = _i;
                TargetForm.Refresh();
            }
        }
开发者ID:itktc,项目名称:projectktc-v2,代码行数:13,代码来源:FormFader.cs

示例7: FadeIn

        public void FadeIn(Form TargetForm, double FadeStep)
        {
            if (TargetForm.Visible == false)
            {
                TargetForm.Opacity = 0;
                TargetForm.Visible = true;
            }

            for (_i = 0; _i <= _MaxOpacity; _i += FadeStep)
            {
                TargetForm.Opacity = _i;
                TargetForm.Refresh();
            }
        }
开发者ID:itktc,项目名称:projectktc-v2,代码行数:14,代码来源:FormFader.cs

示例8: SpawnAnimationThread

 public static void SpawnAnimationThread(LayoutEngine layoutEngine, Form form, int interFrameSleepTimeMillis)
 {
     BackgroundWorker animationThread = new BackgroundWorker();
     animationThread.WorkerReportsProgress = true;
     animationThread.WorkerSupportsCancellation = true;
     animationThread.DoWork += new DoWorkEventHandler(delegate(object sender, DoWorkEventArgs e)
     {
         while (true)
         {
             layoutEngine.incrementLayout();
             Thread.Sleep(interFrameSleepTimeMillis);
             //Console.Out.WriteLine("Animating " + i);
             animationThread.ReportProgress(0);
         }
     });
     animationThread.ProgressChanged += new ProgressChangedEventHandler(delegate(object sender, ProgressChangedEventArgs e)
     {
         form.Refresh();
     });
     animationThread.RunWorkerAsync();
 }
开发者ID:curran,项目名称:Dynamic-Graphics,代码行数:21,代码来源:Animation.cs

示例9: CardQuizzer

        //https://stackoverflow.com/questions/5427020/prompt-dialog-in-windows-forms
        public static void CardQuizzer(string caption, string text)
        {
            Form prompt = new Form();
            prompt.Width = 500;
            prompt.Height = 500;
            prompt.FormBorderStyle = FormBorderStyle.FixedDialog;
            prompt.Text = caption;
            prompt.StartPosition = FormStartPosition.CenterScreen;
            Label textLabel = new Label() { Left = 50, Top = 20, Text = text };
            TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 };
            Button confirmation = new Button() { Text = "Confirm", Left = 300, Width = 100, Top = 70, DialogResult = DialogResult.OK };
            Button denial = new Button() { Text = "Update", Left = 200, Width = 100, Top = 70};
            confirmation.Click += (sender, e) => { prompt.Close(); };
            denial.Click += (sender, e) => { prompt.Refresh(); }; //maybe refreshes form, build method to [.Refresh() or .Update()]
            //prompt.Controls.Add(textBox);
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(denial);
            prompt.Controls.Add(textLabel);
            //prompt.AcceptButton = confirmation;

            prompt.ShowDialog();
        }
开发者ID:MrCythos,项目名称:JapaneseFlashCardForm,代码行数:23,代码来源:FlashCardTester.cs

示例10: FadeForm

 /// <summary>
 ///     Function used to fade out a form using a user defined number
 ///     of steps.
 /// </summary>
 /// <param name="f">The Windows form to fade out</param>
 /// <param name="NumberOfSteps">The number of steps used to fade the form</param>
 public static void FadeForm(Form form, byte NumberOfSteps, bool fadeIn)
 {
     float StepVal = (float)(100f / NumberOfSteps);
     float fOpacity = 0;
     if (!fadeIn)
     {
         fOpacity = 100f;
     }
     for (byte b = 0; b < NumberOfSteps; b++)
     {
         form.Opacity = fOpacity / 100;
         form.Refresh();
         if (fadeIn)
         {
             fOpacity += StepVal;
         }
         else
         {
             fOpacity -= StepVal;
         }
     }
 }
开发者ID:jspraul,项目名称:pop3pipe,代码行数:28,代码来源:MainWindow.cs

示例11: OffscreenGrab

		/// <summary>
		/// Gets an image snapshot of the specified control, which does not have to be
		/// mapped to a <see cref="System.Windows.Forms.Form"/> and does not have to be
		/// fully visible.
		/// </summary>
		/// <param name="control">The control to get an image snapshot of.</param>
		/// <returns>An image snapshot of the control.</returns>
		public static Image OffscreenGrab(Control control) {
			// Save the old parent and location.
			Control oldParent = control.Parent;
			Point oldLocation = control.Location;

			// Create a form offscreen
			Form transpForm = new Form();
			transpForm.StartPosition = FormStartPosition.Manual;
			transpForm.Location = new Point(Screen.PrimaryScreen.Bounds.Right + 10, 0);
			transpForm.ClientSize = new Size(control.Width + 10, control.Height + 10);

			// Make the form semi-transparent so windows turns on layering.
			transpForm.Opacity = .8;

			// Add the control.
			transpForm.Controls.Add(control);
			control.Location = new Point(0, 0);

			// Show the form (offscreen).
			transpForm.Show();
			transpForm.Visible = true;
			transpForm.Refresh();
			transpForm.Update();

			// Grab the control.
			Image img = GrabControl(control);

			// Put the control back on its original form.
			control.Parent = oldParent;
			control.Location = oldLocation;

			// Get rid of our temporary form.
			transpForm.Close();

			// Return the image.
			return img;
		}
开发者ID:CreeperLava,项目名称:ME3Explorer,代码行数:44,代码来源:PXUtil.cs

示例12: ThreadFunction

        private void ThreadFunction()
        {
            try
            {
                // show window
                Form window = new Form();
                window.FormClosing += FormOnClose;
                window.Text = "Map";
                //window.Size = new System.Drawing.Size(800, 600);
                window.AutoSize = true;

                while (true)
                {
                    lock (this)
                    {
                        if (bitmap != null)
                        {
                            if (window.Visible != visible)
                            {
                                if (visible)
                                {
                                    if (first)
                                    {
                                        PictureBox picture = new PictureBox();
                                        picture.Image = bitmap;
                                        picture.SizeMode = PictureBoxSizeMode.AutoSize;
                                        window.Controls.Add(picture);
                                        first = false;
                                    }
                                    window.Show();
                                }
                                else
                                {
                                    window.Hide();
                                }
                            }
                        }
                        if (updated)
                        {
                            if (window.Visible)
                            {
                                window.Refresh();
                            }
                            updated = false;
                        }
                        if (window.Visible)
                        {
                            Application.DoEvents();
                        }
                    }
                    Thread.Sleep(100);
                }
            }
            catch (ThreadInterruptedException e)
            {
                // do nothing
            }
        }
开发者ID:ipo,项目名称:AGBA,代码行数:58,代码来源:MapWindow.cs

示例13: CaptureWindowWithDWM

        /// <summary>
        /// Make a full-size thumbnail of the captured window on a new topmost form, and capture
        /// this new form with a black and then white background. Then compute the transparency by
        /// difference between the black and white versions.
        /// This method has these advantages:
        /// - the full form is captured even if it is obscured on the Windows desktop
        /// - there is no problem with unpredictable Z-order anymore (the background and
        ///   the window to capture are drawn on the same window)
        /// </summary>
        /// <param name="handle">handle of the window to capture</param>
        /// <param name="windowRect">the bounds of the window</param>
        /// <param name="redBGImage">the window captured with a red background</param>
        /// <param name="captureRedBGImage">whether to do the capture of the window with a red background</param>
        /// <returns>the captured window image</returns>
        private static Image CaptureWindowWithDWM(IntPtr handle, Rectangle windowRect, out Bitmap redBGImage, Color backColor)
        {
            Image windowImage = null;
            redBGImage = null;

            if (backColor != Color.White)
            {
                backColor = Color.FromArgb(255, backColor.R, backColor.G, backColor.B);
            }

            using (Form form = new Form())
            {
                form.StartPosition = FormStartPosition.Manual;
                form.FormBorderStyle = FormBorderStyle.None;
                form.ShowInTaskbar = false;
                form.BackColor = backColor;
                form.TopMost = true;
                form.Bounds = CaptureHelpers.GetWindowRectangle(handle, false);

                IntPtr thumb;
                NativeMethods.DwmRegisterThumbnail(form.Handle, handle, out thumb);

                SIZE size;
                NativeMethods.DwmQueryThumbnailSourceSize(thumb, out size);

            #if DEBUG
                DebugHelper.WriteLine("Rectangle Size: " + windowRect.ToString());
                DebugHelper.WriteLine("Window    Size: " + size.ToString());
            #endif

                if (size.Width <= 0 || size.Height <= 0)
                {
                    return null;
                }

                DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES();
                props.dwFlags = NativeMethods.DWM_TNP_VISIBLE | NativeMethods.DWM_TNP_RECTDESTINATION | NativeMethods.DWM_TNP_OPACITY;
                props.fVisible = true;
                props.opacity = (byte)255;
                props.rcDestination = new RECT(0, 0, size.Width, size.Height);

                NativeMethods.DwmUpdateThumbnailProperties(thumb, ref props);

                form.Show();
                System.Threading.Thread.Sleep(250);

                if (form.BackColor != Color.White)
                {
                    // no need for transparency; user has requested custom background color
                    NativeMethods.ActivateWindowRepeat(form.Handle, 250);
                    windowImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;
                }
                else if (form.BackColor == Color.White)
                {
                    // transparent capture
                    NativeMethods.ActivateWindowRepeat(handle, 250);
                    Bitmap whiteBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;

                    form.BackColor = Color.Black;
                    form.Refresh();
                    NativeMethods.ActivateWindowRepeat(handle, 250);
                    Bitmap blackBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;

                    // Capture rounded corners with except for Windows 8
                    if (ZAppHelper.IsWindows8())
                    {
                        form.BackColor = Color.Red;
                        form.Refresh();
                        NativeMethods.ActivateWindowRepeat(handle, 250);
                        redBGImage = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;
                    }

                    form.BackColor = Color.White;
                    form.Refresh();
                    NativeMethods.ActivateWindowRepeat(handle, 250);
                    Bitmap whiteBGImage2 = Screenshot.CaptureRectangleNative(windowRect) as Bitmap;

                    // Don't do transparency calculation if an animated picture is detected
                    if (whiteBGImage.AreBitmapsEqual(whiteBGImage2))
                    {
                        windowImage = HelpersLib.GraphicsHelper.Core.ComputeOriginal(whiteBGImage, blackBGImage);
                    }
                    else
                    {
                        DebugHelper.WriteLine("Detected animated image => cannot compute transparency");
                        form.Close();
//.........这里部分代码省略.........
开发者ID:modulexcite,项目名称:ZScreen_Google_Code,代码行数:101,代码来源:Capture.cs

示例14: UpdateFonts

 public static void UpdateFonts(Form form)
 {
     foreach (Control c in form.Controls)
     {
         if (c is TextBox || c is DataGridView || c is ListBox)
         {
             c.Font = new Font(Properties.Settings.Default.Fonts[0], c.Font.Size);
             c.ForeColor = Color.Black;
         }
         else
         {
             c.Font = new Font(Main.GetFont(), c.Font.Size);
             if (c.Name != "bt_Exit" && c.Name != "bt_Back" && c.Name != "bt_Logout")
                 c.ForeColor = Main.GetColor();
         }
     }
     form.Update();
     form.Refresh();
 }
开发者ID:Maelstrom96,项目名称:ClubVideo,代码行数:19,代码来源:Main.cs

示例15: Border

        /// <summary>
        /// Tạo một thể hiện mới với các tham số được truyền vào
        /// </summary>
        /// <param name="frm">Form chứa Border này</param>
        /// <param name="backcolor">Màu nền của Border</param>
        /// <param name="textcolor">Màu chữ tiêu đề của Border</param>
        /// <param name="textsize">Kích thước chữ tiêu đề của Border</param>
        /// <param name="backgroundMoveable">Chỉ định khả năng di chuyển form bằng background</param>
        /// <param name="resizeable">Chỉ định khả năng thay đổi kích thước của form</param>
        public Border(Form frm, Color backcolor, Color textcolor, bool backgroundMoveable, bool resizeable)
        {
            _frm = frm;
            _frm.FormBorderStyle = FormBorderStyle.None;
            BackgroundMoveable = backgroundMoveable;
            Resizeable = resizeable;
            
            AddFormMoveableControls(this, Title);
            
            InitializeComponent(backcolor, textcolor);

            // add event to control
            frm.MouseMove += delegate(object sender, MouseEventArgs e)
            {
                if (e.Y < Height / 2)
                {
                    Timer1.Start();
                    Timer2.Stop();
                }
                else
                {
                    Timer2.Start();
                    Timer1.Stop();
                }
            };

            frm.SizeChanged += delegate(object sender, EventArgs e)
            {
                this.Width = frm.Width;
                CloseBox.Location = new Point(Width - CloseBox.Width, 0);
                NormnalBox.Location = new Point(Width - NormnalBox.Width * 2, 0);
                MiniBox.Location = new Point(Width - MiniBox.Width * 3, 0);
                OpacityTrackbar.Location = new Point(MiniBox.Left - OpacityTrackbar.Width - 5, 2);
                Title.Width = OpacityTrackbar.Left;
                frm.Refresh();
            };

            frm.Paint += delegate(object sender, PaintEventArgs e)
            {
                e.Graphics.DrawRectangle(new Pen(Title.BackColor), new Rectangle(0, 0, frm.Width - 1, frm.Height - 1));
            };


            Controls.Add(Title);
            Controls.Add(OpacityTrackbar);
            Controls.Add(MiniBox);
            Controls.Add(NormnalBox);
            Controls.Add(CloseBox);
            frm.Controls.Add(this);
            this.BringToFront();
        }
开发者ID:khangit96,项目名称:Project-Csharp,代码行数:60,代码来源:Border.cs


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