예제 #1
0
        private VMListBoxItem isOnErrorLabelFor(Point p)
        {
            int i = vmsListBox.IndexFromPoint(p);

            if (i == ListBox.NoMatches)
            {
                return(null);
            }

            VMListBoxItem item = vmsListBox.Items[i] as VMListBoxItem;

            if (item == null)
            {
                return(null);
            }

            Rectangle bounds = vmsListBox.GetItemRectangle(i);

            Size s;

            using (Font boldFont = new Font(vmsListBox.Font, FontStyle.Bold))
            {
                using (Graphics graphics = vmsListBox.CreateGraphics())
                {
                    s = Drawing.MeasureText(graphics, item.GetError(),
                                            boldFont, bounds.Size, TextFormatFlags.Right | TextFormatFlags.VerticalCenter);
                }
            }

            Rectangle ErrorTextBounds = new Rectangle(bounds.Right - s.Width - RIGHT_PADDING, bounds.Top, s.Width, s.Height);

            return(ErrorTextBounds.Contains(p) ? item : null);
        }
예제 #2
0
        void UpdateVMWithError(string opaqueRef, string message, Solution solution)
        {
            VMListBoxItem vmlbi = vms[opaqueRef];

            vmlbi.UpdateError(message, solution);

            Program.Invoke(this, vmsListBox.Refresh);
        }
예제 #3
0
        void vmsListBox_MouseMove(object sender, MouseEventArgs e)
        {
            VMListBoxItem item = isOnErrorLabelFor(e.Location);

            if (item != null && item.hasSolution())
            {
                Cursor.Current = Cursors.Hand;
            }
            else
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #4
0
        void vmsListBox_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            VMListBoxItem vmlbi = isOnErrorLabelFor(e.Location);

            if (vmlbi == null || !vmlbi.hasSolution())
            {
                return;
            }

            AsyncAction a = vmlbi.Solve();

            if (a != null)
            {
                a.Completed += solveActionCompleted;
            }

            vmsListBox.Refresh();
        }
예제 #5
0
        void vmsListBox_DrawItem(object sender, DrawItemEventArgs e)
        {
            using (SolidBrush backBrush = new SolidBrush(vmsListBox.BackColor))
            {
                e.Graphics.FillRectangle(backBrush, e.Bounds);
            }

            if (e.Index == -1)
            {
                return;
            }

            VMListBoxItem item = vmsListBox.Items[e.Index] as VMListBoxItem;

            using (Font basicFont = new Font(e.Font, FontStyle.Regular))
            {
                vmsListBox.WilkieSpecial(Images.GetImage16For(item.Icon), item.ToString(), item.GetError(), Color.Red, basicFont, e);
            }
        }
예제 #6
0
        private void populateVMs()
        {
            Program.AssertOnEventThread();

            deregisterVMEvents();
            Dictionary <string, AsyncAction> solveActionsByUuid = new Dictionary <string, AsyncAction>();

            foreach (VMListBoxItem i in vms.Values)
            {
                solveActionsByUuid.Add(i.GetVM().uuid, i.solutionAction);
            }
            vms = new Dictionary <string, VMListBoxItem>();

            vmsListBox.BeginUpdate();
            try
            {
                vmsListBox.Items.Clear();

                foreach (VM vm in connection.ResolveAll(host.resident_VMs))
                {
                    if (vm.is_control_domain || vm.is_a_template)
                    {
                        continue;
                    }

                    vm.PropertyChanged += new PropertyChangedEventHandler(VM_PropertyChanged);
                    VMListBoxItem vmlbi = new VMListBoxItem(this, vm);
                    if (solveActionsByUuid.ContainsKey(vm.uuid))
                    {
                        vmlbi.solutionAction = solveActionsByUuid[vm.uuid];
                    }
                    vms.Add(vm.opaque_ref, vmlbi);
                    vmsListBox.Items.Add(vmlbi);
                }
            }
            finally
            {
                vmsListBox.EndUpdate();
                RefreshEntermaintenanceButton();
            }
        }