Пример #1
0
        /// <summary>
        /// activated from the Consumer() thread, runs on the UI thread
        /// </summary>
        /// <param name="o"></param>
        private void UpdateMaxDeaths(object o)
        {
            QueueArgs arg = o as QueueArgs;

            if (arg != null)
            {
                textBoxMax.Text = arg.maxDeaths.ToString();
            }
        }
Пример #2
0
        /// <summary>
        /// main form wants to remove a listing
        /// </summary>
        /// <param name="idx"></param>
        public void RemoveAt(int idx)
        {
            QueueArgs arg = new QueueArgs {
                type = OverlayCommand.REMOVE, index = idx
            };

            queueArgs.Enqueue(arg);
            dataSignal.Set();
        }
Пример #3
0
        /// <summary>
        /// main form wants to position the overlay
        /// </summary>
        /// <param name="size"></param>
        /// <param name="loc"></param>
        public void SetLocation(Size size, Point loc)
        {
            QueueArgs arg = new QueueArgs {
                type = OverlayCommand.LOCATE, size = size, loc = loc
            };

            queueArgs.Enqueue(arg);
            dataSignal.Set();
        }
Пример #4
0
        /// <summary>
        /// main form signals start of combat
        /// </summary>
        public void CombatStart()
        {
            QueueArgs arg = new QueueArgs {
                type = OverlayCommand.RESET
            };

            queueArgs.Enqueue(arg);
            dataSignal.Set();
        }
Пример #5
0
        /// <summary>
        /// main form sets the max death field
        /// </summary>
        /// <param name="maxDeaths"></param>
        public void SetMaxDeaths(int maxDeaths)
        {
            QueueArgs arg = new QueueArgs {
                type = OverlayCommand.MAX_DEATHS, maxDeaths = maxDeaths
            };

            queueArgs.Enqueue(arg);
            dataSignal.Set();
        }
Пример #6
0
        /// <summary>
        /// main form wants to show or hide the overlay
        /// </summary>
        /// <param name="visible"></param>
        public void SetVisibility(bool visible)
        {
            QueueArgs arg = new QueueArgs {
                type = OverlayCommand.VISIBILITY, visible = visible
            };

            queueArgs.Enqueue(arg);
            dataSignal.Set();
        }
Пример #7
0
        /// <summary>
        /// activated from the Consumer() thread, runs on the UI thread
        /// </summary>
        /// <param name="o"></param>
        private void RemoveItem(object o)
        {
            QueueArgs arg = o as QueueArgs;

            if (arg != null)
            {
                listBox1.Items.RemoveAt(arg.index);
                textBoxDeaths.Text = listBox1.Items.Count.ToString();
            }
        }
Пример #8
0
        /// <summary>
        /// main form wants to add a death to the list
        /// </summary>
        /// <param name="dd"></param>
        public void AddDeath(WhoDied dd)
        {
            QueueArgs arg = new QueueArgs {
                type = OverlayCommand.DEATH, count = dd.deathCount, who = dd.who, index = dd.killedAtIndex
            };

            encounterData = dd.ed;
            queueArgs.Enqueue(arg);
            dataSignal.Set();
        }
Пример #9
0
        /// <summary>
        /// activated from the Consumer() thread, runs on the UI thread
        /// </summary>
        /// <param name="o"></param>
        private void LocateForm(object o)
        {
            QueueArgs arg = o as QueueArgs;

            if (arg != null)
            {
                //if we try to set the location prior to _Load() it won't take
                // so save a copy for use in _Load() in case it hasn't happened yet
                this.Size     = mSize = arg.size;
                this.Location = mLoc = arg.loc;
            }
        }
Пример #10
0
        /// <summary>
        /// activated from the Consumer() thread, runs on the UI thread
        /// </summary>
        /// <param name="o"></param>
        private void UpdateVisibility(object o)
        {
            QueueArgs arg = o as QueueArgs;

            if (arg != null)
            {
                this.Visible = arg.visible;
                if (arg.visible)
                {
                    this.TopMost = true; //just to make sure
                }
            }
        }
Пример #11
0
        /// <summary>
        /// activated from the Consumer() thread, runs on the UI thread
        /// </summary>
        /// <param name="o"></param>
        private void UpdateForm(object o)
        {
            QueueArgs w = o as QueueArgs;

            if (w != null)
            {
                textBoxDeaths.Text = w.count.ToString();
                WhoDied whoDied = new WhoDied {
                    who = w.who, killedAtIndex = w.index, deathCount = w.count, ed = encounterData
                };
                listBox1.Items.Insert(0, whoDied);
            }
        }
Пример #12
0
        /// <summary>
        /// process tasks from the main form via queue
        /// </summary>
        private void Consumer()
        {
            Task.Run(() =>
            {
                while (runConsumer)
                {
                    dataSignal.WaitOne();

                    try
                    {
                        QueueArgs data = null;
                        while (queueArgs.TryDequeue(out data))
                        {
                            if (data != null)
                            {
                                switch (data.type)
                                {
                                case OverlayCommand.DEATH:
                                    mUiContext.Post(UpdateForm, data);
                                    break;

                                case OverlayCommand.VISIBILITY:
                                    mUiContext.Post(UpdateVisibility, data);
                                    break;

                                case OverlayCommand.MAX_DEATHS:
                                    mUiContext.Post(UpdateMaxDeaths, data);
                                    break;

                                case OverlayCommand.RESET:
                                    mUiContext.Post(Clear, null);
                                    break;

                                case OverlayCommand.LOCATE:
                                    mUiContext.Post(LocateForm, data);
                                    break;

                                case OverlayCommand.REMOVE:
                                    mUiContext.Post(RemoveItem, data);
                                    break;
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            });
        }
Пример #13
0
 public Source(string topicName, string projectId, string subscriptionId)
 {
     Exchange  = new Exchange(topicName);
     QueueArgs = new QueueArgs(subscriptionId);
     ProjectId = projectId;
 }