Exemplo n.º 1
0
        private void perksList_DoubleClick_1(object sender, EventArgs e)
        {
            saveCurrentPerk();
            BrightIdeasSoftware.OLVListItem what = perksList.GetItem(perksList.SelectedIndex);
            int  num = int.Parse(what.Text);
            Perk p   = Data.GetPerk(num);

            loadPerk(p);
        }
Exemplo n.º 2
0
        private void btnRemove_Click(object sender, EventArgs e)
        {
            saveCurrentPerk();
            BrightIdeasSoftware.OLVListItem what = perksList.GetItem(perksList.SelectedIndex);
            int num = int.Parse(what.Text);

            Data.RemovePerk(num);

            perksList.RebuildColumns();
        }
Exemplo n.º 3
0
        int IComparer.Compare(Object lhs, Object rhs)
        {
            System.Diagnostics.Debug.Assert(lhs is BrightIdeasSoftware.OLVListItem && rhs is BrightIdeasSoftware.OLVListItem);

            BrightIdeasSoftware.OLVListItem xolv = (BrightIdeasSoftware.OLVListItem)lhs;
            BrightIdeasSoftware.OLVListItem yolv = (BrightIdeasSoftware.OLVListItem)rhs;

            System.Diagnostics.Debug.Assert(xolv.RowObject is WelcomeListView.InternalRootObject && yolv.RowObject is WelcomeListView.InternalRootObject);

            WelcomeListView.InternalRootObject rootObjectx = ((WelcomeListView.InternalRootObject)xolv.RowObject);
            WelcomeListView.InternalRootObject rootObjecty = ((WelcomeListView.InternalRootObject)yolv.RowObject);

            return(mGoCompare(mSortOrder == SortOrder.Ascending, rootObjectx, rootObjecty));
        }
Exemplo n.º 4
0
        private void treeListView_CellDoubleClick(object sender, MouseEventArgs e)
        {
            BrightIdeasSoftware.OLVListItem curRow = this.treeListView.SelectedItem;
            var idElemCell = curRow.GetSubItem(1);

            idToSelect = int.Parse(idElemCell.Text);

            var idViewCell = curRow.GetSubItem(3);

            idViewToOpen = int.Parse(idViewCell.Text);

            this.DialogResult = DialogResult.Yes;
            this.Close();
        }
Exemplo n.º 5
0
        private void recipeList_DoubleClick(object sender, EventArgs e)
        {
            BrightIdeasSoftware.OLVListItem what = recipeList.GetItem(recipeList.SelectedIndex);
            decimal num = decimal.Parse(what.Text);
            Recipe  r   = Data.GetRecipe((int)num);

            if (r == null)
            {
                Log("Internal error: could not load recipe.");
                return;
            }

            loadRecipe(r);
            Log("Recipe loaded");
        }
Exemplo n.º 6
0
        private string setHTMLSelectView(object sender, bool isEmail)
        {
            try
            {
                var olv = sender as BrightIdeasSoftware.ObjectListView;

                //If nothing is selected, show a dark empty background
                if (olv == null || (!isEmail && olv.SelectedItems.Count < 1))
                {
                    return("<body style = \"background-color: #2b2b2b\" />");
                }

                int itemCount     = 0;
                var htmlFormatter = new HTMLFormatter();

                if (isEmail)
                {
                    itemCount = olv.Items.Count;
                    htmlFormatter.SetBody(null, ("FiOS Health Check - " + DateTime.Today.ToString("MM/dd/yyyy")));
                }
                else
                {
                    itemCount = olv.SelectedItems.Count;
                    htmlFormatter.SetBody("#777677");
                }

                //Create an array since OLV Item collections does not have an enumerator for linq
                BrightIdeasSoftware.OLVListItem[] selectedOlvLis = new BrightIdeasSoftware.OLVListItem[itemCount];

                //If email, copy all items in OLV to array. Otherwise copy only selected items.
                if (isEmail)
                {
                    olv.Items.CopyTo(selectedOlvLis, 0);
                }
                else
                {
                    olv.SelectedItems.CopyTo(selectedOlvLis, 0);
                }

                //Group health rollups on the server role to be able to display the results under each role
                var roles = selectedOlvLis.Select(x => x.RowObject as HealthRollup).GroupBy(x => x.Server.HostRole)
                            .Select(x => new { x.Key, HostNames = x.Select(y => y.Server) });

                //loop through each role, creating the selected servers and displaying their result and any errors if they exist
                foreach (var role in roles.OrderBy(x => x.Key))
                {
                    htmlFormatter.SetRole(role.Key.ToString());

                    foreach (var svr in role.HostNames.OrderBy(x => !x.IsActive).ThenBy(x => x.HostName))
                    {
                        if (!svr.IsActive)
                        {
                            htmlFormatter.BeginTable(string.Format("{0} (Inactive)", svr.HostName), "#2f285b");
                        }
                        else
                        {
                            htmlFormatter.BeginTable(svr.HostName);
                        }

                        var hru = selectedOlvLis.Select(x => x.RowObject as HealthRollup).Where(x => x.Server.HostName.Equals(svr.HostName)).FirstOrDefault();

                        foreach (var err in hru.Errors)
                        {
                            writeVerbose(string.Format("{0} has {1} errors for check type {2}. Result: {3}", svr.HostName, err.Error.Count, err.HCType, err.Result));
                            htmlFormatter.AddStatusRow(err.HCType.ToString(), err.Result);
                            if (err.Error.Count > 0)
                            {
                                writeVerbose(string.Format("{0} - Check Type {1} - Errors: {2}", svr.HostName, err.HCType, string.Join(System.Environment.NewLine, err.Error)));
                                htmlFormatter.AddErrorDescriptionRows(err.Error);
                            }
                        }

                        htmlFormatter.EndTable();
                    }
                }
                return(htmlFormatter.ToString());
            }
            catch (Exception ex)
            {
                writeError(string.Format("Error in selection changed delegate. {0}", ex.Message), 10900, System.Diagnostics.TraceEventType.Error);
                return(string.Empty);
            }
        }