예제 #1
0
        private void ChangePanel(TargetMediator aTarget)
        {
            Control ui = aTarget.CurrentApplet.Ui;

            ui.Name = "Ui";
            ui.Dock = DockStyle.Fill;
            tabControl1.SelectedTab.Controls.RemoveByKey("Ui");
            tabControl1.SelectedTab.Controls.Add(ui);
        }
예제 #2
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            TargetMediator targetMediator = (TargetMediator)listView1.SelectedItems[0].Tag;

            targetMediator.Activate(targetMediator.AppletSelectedIndex);

            SetSelectedTab(targetMediator.AppletSelectedIndex);
            ChangePanel(targetMediator);
            SetStatusBar(targetMediator);
            iHelper.ApplicationOptions.LastBoxSelected = targetMediator.Target.Box.MacAddress;
        }
예제 #3
0
        private void ChangeItem(Box aBox)
        {
            ListViewItem   item           = listView1.Items[aBox.MacAddress];
            TargetMediator targetMediator = (TargetMediator)item.Tag;

            SetListViewItem(targetMediator, item);
            listView1.Sort();

            if (listView1.SelectedIndices.Count > 0 && item.Index == listView1.SelectedIndices[0])
            {
                SetStatusBar(targetMediator);
            }
            if (iFormTree != null && !iFormTree.IsDisposed)
            {
                iFormTree.UpdateTree();
            }
        }
예제 #4
0
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            int            appletIndex    = (int)tabControl1.SelectedTab.Tag;
            TargetMediator targetMediator = (TargetMediator)listView1.SelectedItems[0].Tag;

            //when the list view item changes the ui has already been modified
            if (appletIndex == targetMediator.AppletSelectedIndex)
            {
                return;
            }

            targetMediator.Activate(appletIndex);
            ChangePanel(targetMediator);
            SetStatusBar(targetMediator);
        }
예제 #5
0
        private void AddItem(EventArgsBox e)
        {
            Target         target         = new Target(e.BoxArg);
            TargetMediator targetMediator = new TargetMediator(target, iManager);

            ListViewItem item = new ListViewItem(new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "" });

            SetListViewItem(targetMediator, item);
            listView1.Items.Add(item);

            //on startup set selected item to the last user selected device
            if (e.BoxArg.MacAddress == iHelper.ApplicationOptions.LastBoxSelected)
            {
                item.Selected             = true;
                pictureBox1.ImageLocation = e.BoxArg.ImageUri;
            }
            if (iFormTree != null && !iFormTree.IsDisposed)
            {
                iFormTree.UpdateTree();
            }
        }
예제 #6
0
        public void BoxAddedHandler(object obj, EventArgsBox e)
        {
            e.BoxArg.EventBoxChanged += BoxChangedHandler;

            // made synchronous to handle starting from fallback case, box added and box changed called in succession, so targetMediator.Target.AddBoxChangeEvent is missed otherwise
            this.Invoke(
                (MethodInvoker) delegate() {
                if (listView1.Items.ContainsKey(e.BoxArg.MacAddress))
                {
                    //if the box is being added due to a room change update the item
                    TargetMediator targetMediator = (TargetMediator)listView1.Items[e.BoxArg.MacAddress].Tag;
                    targetMediator.Target.AddBoxChangeEvent(e.BoxArg);

                    ChangeItem(e.BoxArg);
                }
                else
                {
                    AddItem(e);
                }
            }
                );
        }
예제 #7
0
        private void turnDeviceOnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TargetMediator targetMediator = (TargetMediator)listView1.SelectedItems[0].Tag;

            targetMediator.Target.Box.SetStandby(false);
        }
예제 #8
0
        private void rebootDeviceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TargetMediator targetMediator = (TargetMediator)listView1.SelectedItems[0].Tag;

            targetMediator.Target.Box.Reboot();
        }
예제 #9
0
 private void SetStatusBar(TargetMediator aTarget)
 {
     nameStatus.Text      = aTarget.ToString();
     nameStatus.BackColor = aTarget.StatusColor;
 }
예제 #10
0
        private void SetListViewItem(TargetMediator aTargetMediator, ListViewItem aItem)
        {
            aItem.SubItems[0].Text = aTargetMediator.Target.Box.Room;
            aItem.SubItems[1].Text = aTargetMediator.Target.Box.Name;
            aItem.SubItems[2].Text = aTargetMediator.Target.Box.Model;
            aItem.SubItems[3].Text = aTargetMediator.Target.Box.SoftwareVersion;
            if (iBoxes.UpdateCheckInProgress)
            {
                aItem.SubItems[4].Text = "Update Check In Progress";
            }
            else if (iBoxes.UpdateCheckFailed)
            {
                aItem.SubItems[4].Text = "Update Check Failed";
            }
            else if (aTargetMediator.Target.Box.SoftwareUpdateVersion == null)
            {
                aItem.SubItems[4].Text = "Device not found";
            }
            else
            {
                aItem.SubItems[4].Text = aTargetMediator.Target.Box.SoftwareUpdateString(true);
            }
            aItem.SubItems[5].Text = aTargetMediator.Target.Box.IpAddress;
            aItem.SubItems[6].Text = aTargetMediator.Target.Box.MacAddress;
            aItem.SubItems[7].Text = aTargetMediator.Target.Box.StatusText;
            aItem.SubItems[8].Text = aTargetMediator.Target.Box.ProductId;
            string boardTypes = "";

            for (uint i = 0; i < aTargetMediator.Target.Box.BoardType.Length; i++)
            {
                if (boardTypes.Length > 0 && aTargetMediator.Target.Box.BoardType[i].Length > 0)
                {
                    boardTypes += ", ";
                }
                boardTypes += aTargetMediator.Target.Box.BoardType[i];
            }
            string boardDescriptions = "";

            for (uint i = 0; i < aTargetMediator.Target.Box.BoardDescription.Length; i++)
            {
                if (boardDescriptions.Length > 0 && aTargetMediator.Target.Box.BoardDescription[i].Length > 0)
                {
                    boardDescriptions += ", ";
                }
                boardDescriptions += aTargetMediator.Target.Box.BoardDescription[i];
            }
            string boardIds = "";

            for (uint i = 0; i < aTargetMediator.Target.Box.BoardId.Length; i++)
            {
                if (boardIds.Length > 0 && aTargetMediator.Target.Box.BoardId[i].Length > 0)
                {
                    boardIds += ", ";
                }
                boardIds += aTargetMediator.Target.Box.BoardId[i];
            }
            string boardNumbers = "";

            for (uint i = 0; i < aTargetMediator.Target.Box.BoardNumber.Length; i++)
            {
                if (boardNumbers.Length > 0 && aTargetMediator.Target.Box.BoardNumber[i].Length > 0)
                {
                    boardNumbers += ", ";
                }
                boardNumbers += aTargetMediator.Target.Box.BoardNumber[i];
            }
            aItem.SubItems[9].Text  = boardNumbers;
            aItem.SubItems[10].Text = boardTypes;
            aItem.SubItems[11].Text = boardDescriptions;
            aItem.SubItems[12].Text = boardIds;

            aItem.Tag  = aTargetMediator;
            aItem.Name = aTargetMediator.Target.Box.MacAddress;
        }