コード例 #1
0
        protected void AddControl(StateControl stateControl)
        {
            try
            {
                Mutex.Wait();

                try
                {
                    int top = 0;

                    for (int i = 0; i < panelBody.Controls.Count; i++)
                    {
                        Control control = panelBody.Controls[i];

                        control.Top = top;

                        top += control.Height;
                    }

                    stateControl.Top    = top;
                    stateControl.Height = 32;

                    int width = 0;

                    if (panelBody.Controls.Count == 0)
                    {
                        width = panelBody.Width;
                    }
                    else
                    {
                        width = panelBody.Controls[panelBody.Controls.Count - 1].Width;
                    }

                    stateControl.Width = width;

                    stateControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

                    panelBody.Controls.Add(stateControl);

                    stateControl.Enabled = true;
                }
                finally
                {
                    Mutex.Release();
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception, false);
            }
        }
コード例 #2
0
        private void StateControl_Remove(StateControl sender)
        {
            try
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new StateControl.RemoveHandler(StateControl_Remove), new object[] { sender });
                    return;
                }

                RemoveControl(sender);
            }
            catch (Exception exception)
            {
                Log.Error(exception, false);
            }
        }
コード例 #3
0
        protected void RemoveControl(StateControl stateControl)
        {
            try
            {
                Mutex.Wait();

                try
                {
                    panelBody.Controls.Remove(stateControl);

                    UpdateControls();
                }
                finally
                {
                    Mutex.Release();
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception, false);
            }
        }
コード例 #4
0
        public void State_QueuedStream(API.DriveService.State sender, API.DriveService.Stream stream)
        {
            try
            {
                if (InvokeRequired)
                {
                    BeginInvoke(new API.DriveService.State.StreamHandler(State_QueuedStream), new object[] { sender, stream });
                    return;
                }
                stream.OnProgressChanged += Stream_ProgressChanged;

                var control = new StateControl(stream);

                control.OnRemove += StateControl_Remove;

                AddControl(control);
            }
            catch (Exception exception)
            {
                Log.Error(exception, false);
            }
        }
コード例 #5
0
        private void StateControl_Remove(StateControl sender)
        {
            try
              {
            if (InvokeRequired)
            {
              BeginInvoke(new StateControl.RemoveHandler(StateControl_Remove), new object[] {sender});
              return;
            }

            RemoveControl(sender);
              }
              catch (Exception exception)
              {
            Log.Error(exception, false);
              }
        }
コード例 #6
0
        protected void RemoveControl(StateControl stateControl)
        {
            try
              {
            Mutex.Wait();

            try
            {
              panelBody.Controls.Remove(stateControl);

              UpdateControls();
            }
            finally
            {
              Mutex.Release();
            }
              }
              catch (Exception exception)
              {
            Log.Error(exception, false);
              }
        }
コード例 #7
0
        protected void AddControl(StateControl stateControl)
        {
            try
              {
            Mutex.Wait();

            try
            {
              int top = 0;

              for (int i = 0; i < panelBody.Controls.Count; i++)
              {
            Control control = panelBody.Controls[i];

            control.Top = top;

            top += control.Height;
              }

              stateControl.Top = top;
              stateControl.Height = 32;

              int width = 0;

              if (panelBody.Controls.Count == 0)
              {
            width = panelBody.Width;
              }
              else
              {
            width = panelBody.Controls[panelBody.Controls.Count - 1].Width;
              }

              stateControl.Width = width;

              stateControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;

              panelBody.Controls.Add(stateControl);

              stateControl.Enabled = true;
            }
            finally
            {
              Mutex.Release();
            }
              }
              catch (Exception exception)
              {
            Log.Error(exception, false);
              }
        }
コード例 #8
0
        public void State_QueuedStream(API.DriveService.State sender, API.DriveService.Stream stream)
        {
            try
              {
            if (InvokeRequired)
            {
              BeginInvoke(new API.DriveService.State.StreamHandler(State_QueuedStream), new object[] {sender, stream});
              return;
            }
            stream.OnProgressChanged += Stream_ProgressChanged;

            var control = new StateControl(stream);

            control.OnRemove += StateControl_Remove;

            AddControl(control);
              }
              catch (Exception exception)
              {
            Log.Error(exception, false);
              }
        }