Пример #1
0
 private void ptbCancelar_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Este agendamento foi cancelado?", "Questão", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         PictureBox ptbCancelar = new PictureBox();
         ptbCancelar = (PictureBox)sender;
         int posicao = Convert.ToInt32(ptbCancelar.Name.Replace("ptbCancelar", ""));
         agendaVO        = new AgendaVO();
         agendaVO        = listAgenda[posicao];
         agendaVO.Status = 'N';
         AgendaDAO.AtualizarRegistro(agendaVO);
         FlowLayoutPanel flpAgendamentos = (FlowLayoutPanel)(ptbCancelar.FindForm().Controls.Find("flpAgendamentos", false)[0]);
         if (ptbCancelar.FindForm().Name == "frPrincipal")
         {
             listAgenda.Remove(agendaVO);
             AtualizaStatus(flpAgendamentos);
             ExibeAgendamentos(flpAgendamentos, Enum_TipoExibicaoAgenda.hoje);
         }
         else if (ptbCancelar.FindForm().Name == "frAgendados")
         {
             if ((ptbCancelar.FindForm().Controls.Find("panSemana", false)) != null)
             {
                 ExibeAgendamentos(flpAgendamentos, Enum_TipoExibicaoAgenda.semana);
             }
             else if ((ptbCancelar.FindForm().Controls.Find("panSemana", false)) != null)
             {
                 ExibeAgendamentos(flpAgendamentos, Enum_TipoExibicaoAgenda.mes);
             }
         }
     }
     else
     {
         return;
     }
 }
Пример #2
0
        private void Refresh(Image image, PictureBox pictureBox)
        {
            if (pictureBox.FindForm().WindowState == FormWindowState.Minimized)
            {
                return;
            }

            int sourceWidth  = image.Width;
            int sourceHeight = image.Height;

            float nPercent  = 0;
            float nPercentW = 0;
            float nPercentH = 0;

            nPercentW = ((float)pictureBox.Size.Width / (float)sourceWidth);
            nPercentH = ((float)pictureBox.Size.Height / (float)sourceHeight);

            nPercent = nPercentH < nPercentW ? nPercentH : nPercentW;

            int destWidth  = (int)(sourceWidth * nPercent);
            int destHeight = (int)(sourceHeight * nPercent);

            Bitmap   b = new Bitmap(destWidth, destHeight);
            Graphics g = Graphics.FromImage(b);
            {
                g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                g.DrawImage(image, 0, 0, destWidth, destHeight);
                pictureBox.Image = b;
            }
        }
Пример #3
0
        } // Main()

        /*----------------------------------------------------------------*/

        private void picBox1_Click(object sender, EventArgs e)
        {
            PictureBox picBox1 = (PictureBox)sender;

            picBox1.Image = null;

            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.ShowHelp    = true; // [ http://stackoverflow.com/questions/6718148/windows-forms-gui-hangs-when-calling-openfiledialog-showdialog ]
            openFileDialog1.Filter      = "Image Files|*.GIF;*.PNG;*.JPG;*.BMP|All files (*.*)|*.*";
            openFileDialog1.FilterIndex = 1;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try {
                    picBox1.Image = System.Drawing.Image.FromFile(openFileDialog1.FileName);
                } catch (Exception ex) {
                    picBox1.FindForm().BackColor = System.Drawing.Color.Black; // picBox1.Parent;
                    MessageBox.Show("Error: " + ex.Message + "\n" + openFileDialog1.FileName, "Image.FromFile()");
                }
            }
            else
            {
                if (MessageBox.Show("Quit?", "msgTitle", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK)
                {
                    Application.Exit();
                }
                else
                {
                    // loop
                    picBox1_Click(sender, e);
                }
            }
        }
Пример #4
0
        public static void ExitPBOnClick(object sender, EventArgs args)
        {
            if (sender is PictureBox)
            {
                try
                {
                    PictureBox aLabel = (sender as PictureBox);
                    Form       aForm  = aLabel.FindForm();

                    foreach (object obj in aForm.Controls)
                    {
                        if (obj is IDisposable)
                        {
                            (obj as IDisposable).Dispose();
                        }
                    }
                    GC.Collect();

                    aForm.Close();
                }
                catch (Exception)
                {
                    MessageBox.Show("ERROR IN CLOSING- Validators Functions");
                }
            }
        }
Пример #5
0
        private void picBox1_DragDrop(object sender, DragEventArgs e)
        {
            PictureBox picBox1 = (PictureBox)sender;

            picBox1.Image = null;

            // Extract the data from the DataObject-Container into a string list
            string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            try {
                picBox1.Image = System.Drawing.Image.FromFile(FileList[0]);
                picBox1.FindForm().BackColor = System.Drawing.Color.Lime;
            } catch (Exception ex) {
                picBox1.FindForm().BackColor = System.Drawing.Color.Black; // picBox1.Parent;
                MessageBox.Show("Error: " + ex.Message + "\n" + FileList[0], "Image.FromFile()");
                // frmMain.TransparencyKey = System.Drawing.Color.Lime;
            }
        }
Пример #6
0
        public void UpdateTextBackColor(int r, int g, int b)
        {
            return;

            Form   f = _pbImage.FindForm();
            Action setTextBackColor = new Action(() =>
            {
                Color c = Color.FromArgb(r, g, b);

                _tbPickedByDesc.BackColor = c;
                _tbPickedBy.BackColor     = c;
                _tbTeam.BackColor         = c;
            });

            if (f.InvokeRequired)
            {
                f.Invoke(setTextBackColor);
                return;
            }

            setTextBackColor();
        }
Пример #7
0
        //

        public static void Update(PictureBox GUIPictureBox)
        {
            if (!isStarted)
            {
                Start();

                isStarted = true;
            }

            if (GUIPictureBox.FindForm() != null)
            {
                isDisplayed = GUIPictureBox.FindForm().WindowState != FormWindowState.Minimized;
                isFocused   = GUIPictureBox.FindForm().Focused;
            }
            //

            if (isFocused)
            {
                Input.Update();           // Энтропия ввода
            }
            //

            CurrentPicture = GUIPictureBox;

            if (CurrentPicture.Width != 0 && CurrentPicture.Height != 0)
            {
                CurrentPicture.Image = null;
                CurrentPicture.Image = new Bitmap(CurrentPicture.Width, CurrentPicture.Height);

                Width  = CurrentPicture.Width;
                Height = CurrentPicture.Height;
            }

            G = Graphics.FromImage(CurrentPicture.Image);
            G.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            //
            ResetOffset();
            ResetClip();
        }
Пример #8
0
        //--------------------------------------------------------
        //	DataPanel_DragDrop
        //		On Drop moves picture box from origin to destination
        //		if able
        //--------------------------------------------------------
        private void DataPanel_DragDrop(object sender, DragEventArgs e)
        {
            // Check that the sender is a picturebox
            PictureBox temp = e.Data.GetData(typeof(PictureBox)) as PictureBox;

            if (temp == null)
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            // Check that it came from DataGroupForm
            DataGroupForm f = temp.FindForm() as DataGroupForm;

            if (f == null)
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            // Check if PictureBox is in Ungrouped List
            if (f.unGroupedList.Contains(temp))
            {
                f.unGroupedList.Remove(temp);
                f.ResizeUngrouped();

                temp.Parent = m_dataPanel;

                this.m_dataList.Add(temp);
                this.ResizeData();

                return;
            }

            // Check if PictureBox is in a Group
            foreach (Group g in f.groupList)
            {
                if (g.m_dataList.Contains(temp))
                {
                    g.m_dataList.Remove(temp);
                    g.ResizeData();

                    temp.Parent = m_dataPanel;

                    this.m_dataList.Add(temp);
                    this.ResizeData();

                    return;
                }
            }
        }
Пример #9
0
        public static void MinimizePBOnClick(object sender, EventArgs args)
        {
            if (sender is PictureBox)
            {
                try
                {
                    PictureBox aLabel = (sender as PictureBox);
                    Form       aForm  = aLabel.FindForm();


                    aForm.WindowState = FormWindowState.Minimized;
                }
                catch (Exception)
                {
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Where the Magic is happening
        /// Regrouping all the functions to get the game logic
        /// </summary>
        /// <returns></returns>
        private bool EngineThread()
        {
            Drawer = new Drawer(DrawingArea);
            Form form = DrawingArea.FindForm();

            if (form != null)
            {
                form.KeyDown += Form_KeyDown;
                form.KeyUp   += Form_KeyUp;
            }
            DrawingArea.MouseDown += DrawingArea_MouseDown;
            DrawingArea.MouseUp   += DrawingArea_MouseUp;
            DrawingArea.MouseMove += DrawingArea_MouseMove;
            EngineActive           = OnCreate();
            timer          = new System.Timers.Timer();
            timer.Enabled  = true;
            timer.Interval = 1;
            timer.Elapsed += Timer_Elapsed;
            timer.Start();
            return(EngineActive);
        }
Пример #11
0
        internal static void pic_Click(object sender, EventArgs e)
        {
            PictureBox pic = sender as PictureBox;
            // MessageBox.Show(pic.Tag.ToString());
            // MessageBox.Show(.Text);
            Form f = pic.FindForm();

            if (f != null)
            {
                Type     t    = f.GetType();
                MenuInfo info = pic.Tag as MenuInfo;
                try
                {
                    t.InvokeMember(info.MethodName, BindingFlags.Default | BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, f, new object[] { info.Right });
                }
                catch (MissingMethodException ex)
                {
                    //MessageBoxHelper.Show("找不到方法"+info.MethodName);
                }
            }
            //Console.WriteLine("click the menuItem!"+tmp.Text);
            //throw new Exception("The method or operation is not implemented.");
        }
Пример #12
0
        /// <summary>
        /// Evento click disparado pelo Panel que contem a imagem e o nome do funcionário
        /// </summary>
        private void Funcionario_Click(object sender, EventArgs e)
        {
            Panel panFuncionario;

            if (sender is Panel)
            {
                panFuncionario = (Panel)sender;
                SelecionaFuncionario(panFuncionario);
            }
            else if (sender is PictureBox)
            {
                PictureBox      ptbImagemFuncionario = (PictureBox)sender;
                FlowLayoutPanel flp = (FlowLayoutPanel)(ptbImagemFuncionario.FindForm().Controls.Find("panAgendamento", false)[0]).Controls.Find("flpFuncionarios", false)[0];
                panFuncionario = (Panel)flp.Controls.Find(ptbImagemFuncionario.Name, false)[0];
                SelecionaFuncionario(panFuncionario);
            }
            else if (sender is TextBox)
            {
                TextBox         txtNomeFuncionario = (TextBox)sender;
                FlowLayoutPanel flp = (FlowLayoutPanel)(txtNomeFuncionario.FindForm().Controls.Find("panAgendamento", false)[0]).Controls.Find("flpFuncionarios", false)[0];
                panFuncionario = (Panel)flp.Controls.Find(txtNomeFuncionario.Name, false)[0];
                SelecionaFuncionario(panFuncionario);
            }
        }