示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SendCommand"/> class.
 /// </summary>
 /// <param name="groupId">The group identifier.</param>
 /// <param name="playlistItemId">The playlist identifier of the playing item.</param>
 /// <param name="when">The UTC time when to execute the command.</param>
 /// <param name="command">The command.</param>
 /// <param name="positionTicks">The position ticks, for commands that require it.</param>
 /// <param name="emittedAt">The UTC time when this command has been emitted.</param>
 public SendCommand(Guid groupId, Guid playlistItemId, DateTime when, SendCommandType command, long?positionTicks, DateTime emittedAt)
 {
     GroupId        = groupId;
     PlaylistItemId = playlistItemId;
     When           = when;
     Command        = command;
     PositionTicks  = positionTicks;
     EmittedAt      = emittedAt;
 }
示例#2
0
 /// <summary>
 /// Builds a new playback command with some default values.
 /// </summary>
 /// <param name="type">The command type.</param>
 /// <value>The SendCommand.</value>
 private SendCommand NewSyncPlayCommand(SendCommandType type)
 {
     return(new SendCommand()
     {
         GroupId = _group.GroupId.ToString(),
         Command = type,
         PositionTicks = _group.PositionTicks,
         When = DateToUTCString(_group.LastActivity),
         EmittedAt = DateToUTCString(DateTime.UtcNow)
     });
 }
示例#3
0
 //send cmd id
 public static void SendCommand(Socket client, SendCommandType type)
 {
     byte[] buffer = BitConverter.GetBytes(CLT_MAGIC | (byte)type);
     SendRaw(client, buffer);
 }
示例#4
0
        private void propertiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var settingsForm = new SendCommandToolPropertiesForm()
            {
                HostHwnd     = this.m_HostWindowHwnd,
                ToolWidht    = this.Size.Width,
                ToolHeight   = this.Size.Height,
                AnchorH      = m_AnchorH,
                AnchorV      = m_AnchorV,
                Commands     = m_Commands,
                CommandType  = m_SendCommandType,
                Sleep        = m_Sleep,
                SleepTimeout = m_SleepTimeout,
                RunOnAllWindowsWithSameTitle = m_RunOnAllWindowsWithSameTitle,
                ToolLeft         = this.Location.X,
                ToolTop          = this.Location.Y,
                BorderColor      = this.m_PenNormal.Color,
                BorderHoverColor = this.m_PenHover.Color,
                TitlePattern     = this.m_TitlePattern,
                ActivateOnHover  = this.ActivateOnHover
            };

            var result = settingsForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                this.m_HostWindowHwnd = settingsForm.HostHwnd;
                this.Size             = new Size(settingsForm.ToolWidht, settingsForm.ToolHeight);
                this.m_AnchorH        = settingsForm.AnchorH;
                this.m_AnchorV        = settingsForm.AnchorV;
                this.m_DrawRectangle  = new Rectangle(0, 0, this.Size.Width - 1, this.Size.Height - 1);

                this.m_Commands        = settingsForm.Commands;
                this.m_SendCommandType = settingsForm.CommandType;

                if (this.m_SendCommandType == SendCommandType.ActivateWindow)
                {
                    int handle;
                    if (int.TryParse(m_Commands, out handle))
                    {
                        if (User32Windows.IsWindow((IntPtr)handle))
                        {
                            if (this.BackgroundImagePath != string.Empty)
                            {
                                var q = MessageBox.Show("The tool already has an background icon,\novervrite?", "Background icon",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                                if (q == DialogResult.No)
                                {
                                    return;
                                }
                            }

                            var icon = User32Windows.GetIcon((IntPtr)handle);

                            if (icon != null)
                            {
                                this.BackgroundImage = icon.ToBitmap();
                            }
                        }
                    }
                }

                this.m_Sleep        = settingsForm.Sleep;
                this.m_SleepTimeout = settingsForm.SleepTimeout;
                this.m_RunOnAllWindowsWithSameTitle = settingsForm.RunOnAllWindowsWithSameTitle;
                this.m_TitlePattern = settingsForm.TitlePattern;

                this.Location = new Point(settingsForm.ToolLeft, settingsForm.ToolTop);

                this.m_PenNormal.Color = settingsForm.BorderColor;
                this.m_PenHover.Color  = settingsForm.BorderHoverColor;

                if (m_TitlePattern != String.Empty)
                {
                    m_TitleRegex = new Regex(m_TitlePattern);
                }
                else
                {
                    m_TitleRegex = null;
                }

                this.ActivateOnHover = settingsForm.ActivateOnHover;
            }
        }