コード例 #1
0
        //Override the OnPrintPage to provide the printing logic for the document
        protected override void OnPrintPage(PrintPageEventArgs ev)
        {
            base.OnPrintPage(ev);
            LeftMargin = ev.MarginBounds.Left;

            //Work out the number of lines per page
            //Use the MarginBounds on the event to do this
            //lpp = ev.MarginBounds.Height  / printFont.GetHeight(ev.Graphics) ;
            float topMargin = ev.MarginBounds.Top;

            topMargin = 25;
            float yPos = topMargin;

            //Now print what we want to print
            Structs.Club    club    = CommonCode.GetClub(this.clubIdToPrint);
            Structs.Shooter shooter = CommonCode.GetShooters(club)[this.currentShooter];
            printHeader(ev, shooter, ref yPos);
            printShooter(ev, shooter, ref yPos);

            //If we have more patrols then print another page
            if (this.currentShooter < CommonCode.GetShooters(club).Length)
            {
                ev.HasMorePages = true;
            }
            else
            {
                ev.HasMorePages = false;
            }
        }
コード例 #2
0
ファイル: FClubs.cs プロジェクト: dasca/WinShooter-Legacy
        private void BtnDeleteClick(object sender, System.EventArgs e)
        {
            Trace.WriteLine("FClubs: btnDelete_Click() started");
            var res =
                MessageBox.Show(
                    "Detta kommer att radera klubben. Är du säker?",
                    "Bekräftelse",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Warning,
                    MessageBoxDefaultButton.Button2);

            if (res == DialogResult.Yes)
            {
                try
                {
                    Trace.WriteLine("FClubs: deleting club:" +
                                    (string)_ddClubs.SelectedValue);
                    _commonCode.DelClub(_commonCode.GetClub((string)_ddClubs.SelectedValue));
                    RestoreWindow();
                }
                catch (System.Data.OleDb.OleDbException exc)
                {
                    Trace.WriteLine("FClubs: Exception while deleting club:" +
                                    exc);
                    if (exc.Message.IndexOf("Shooter") > -1)
                    {
                        MessageBox.Show(
                            "Ett fel uppstod vid radering av klubb.\r\n" +
                            "Detta beror på att det finns skyttar " +
                            "upplagda som tillhör den klubben.",
                            "Ett fel har uppstått",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(
                            "Ett fel uppstod vid radering av klubb.\r\n" +
                            "\r\n" +
                            "Systemmeddelende: " + exc.Message,
                            "Ett fel har uppstått",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                }
            }
            Trace.WriteLine("FClubs: btnDelete_Click() ended");
        }
コード例 #3
0
ファイル: FTeams.cs プロジェクト: dasca/WinShooter-Legacy
        private void populateTeamsDropDownThread()
        {
            Trace.WriteLine("FCompetitors: populateTeamsDropDown() " +
                            "started on thread \"" +
                            Thread.CurrentThread.Name +
                            "\" ( " +
                            Thread.CurrentThread.ManagedThreadId.ToString() +
                            " )");

            if (DdTeams.InvokeRequired)
            {
                Invoke(PopulateTeamsDropDownThreadInvoker);
                return;
            }

            lock (populateTeamsDropDownThreadLock)
            {
                DdTeamsView.Table = null;

                // Get the teams from the database
                Structs.Team[] teams = CommonCode.GetTeams();
                DatasetTeams   ds    = new DatasetTeams();

                // Create the default row
                DatasetTeams.TeamsRow defaultrow =
                    ds.Teams.NewTeamsRow();
                defaultrow.TeamsId   = -1;
                defaultrow.TeamsName = NewTeamString;
                ds.Teams.AddTeamsRow(defaultrow);

                foreach (Structs.Team team in teams)
                {
                    DatasetTeams.TeamsRow row =
                        ds.Teams.NewTeamsRow();
                    row.TeamsId = team.TeamId;
                    string clubName = CommonCode.GetClub(team.ClubId).Name;
                    row.TeamsName = clubName + " - " + team.Name;
                    ds.Teams.AddTeamsRow(row);
                }
                DdTeamsView.Table     = ds.Teams;
                DdTeamsView.Sort      = "TeamsName";
                DdTeams.DisplayMember = "TeamsName";
                DdTeams.ValueMember   = "TeamsId";
            }
            Trace.WriteLine("FCompetitors: populateTeamsDropDown() ended.");
        }
コード例 #4
0
        private string getClubName(string ClubId)
        {
            if (clubs.ContainsKey(ClubId))
            {
                return((string)clubs[ClubId]);
            }

            string name = CommonCode.GetClub(ClubId).Name;

            clubs.Add(ClubId, name);
            return(name);
        }
コード例 #5
0
        private void populatePatrol(Structs.Patrol thisPatrol)
        {
            Trace.WriteLine("FPatrol: populatePatrol started on thread \"" +
                            Thread.CurrentThread.Name + "\" ( " +
                            Thread.CurrentThread.ManagedThreadId.ToString() + " )");

            this.datasetPatrol.shooters.Clear();

            // Populate list with competitors from this patrol
            Structs.Competitor[] competitors =
                CommonCode.GetCompetitors(thisPatrol, "Lane");

            foreach (Structs.Competitor competitor in competitors)
            {
                DatasetPatrol.shootersRow patrolRow =
                    this.datasetPatrol.shooters.NewshootersRow();

                // Fetch data for row
                Structs.Shooter shooter =
                    CommonCode.GetShooter(competitor.ShooterId);
                Structs.Club club =
                    CommonCode.GetClub(shooter.ClubId);
                Structs.Weapon weapon =
                    CommonCode.GetWeapon(competitor.WeaponId);

                // Populate row
                patrolRow.Move         = false;
                patrolRow.competitorId = competitor.CompetitorId;
                patrolRow.Name         = shooter.Givenname + " " + shooter.Surname;
                patrolRow.Club         = club.Name;
                patrolRow.Weapon       = weapon.Manufacturer + "," +
                                         weapon.Model + "," +
                                         weapon.Caliber;
                patrolRow.Lane        = competitor.Lane;
                patrolRow.WeaponClass = weapon.WClass.ToString().Substring(0, 1);

                this.datasetPatrol.shooters.AddshootersRow(patrolRow);
            }
            Trace.WriteLine("FPatrol: populatePatrol ended.");
        }
コード例 #6
0
        private void printPatrol(ref PrintPageEventArgs ev, ref float yPos, int tab)
        {
            printPatrolHeader(ref ev, ref yPos, tab);
            Structs.Competitor[] comps = CommonCode.GetCompetitors(this.patrol, "Lane");

            foreach (Structs.Competitor comp in comps)
            {
                Structs.Shooter shooter = CommonCode.GetShooter(comp.ShooterId);
                Structs.Club    club    = CommonCode.GetClub(shooter.ClubId);

                ev.Graphics.DrawString(comp.Lane.ToString(),
                                       printCompetitorFont, Brushes.Black, this.colLane, yPos, new StringFormat());


                string name = shooter.Givenname + ", " + shooter.Surname;
                while (ev.Graphics.MeasureString(name, printCompetitorFont).Width > (colClub - colName))
                {
                    name = name.Substring(0, name.Length - 1);
                }
                ev.Graphics.DrawString(name,
                                       printCompetitorFont, Brushes.Black, this.colName, yPos, new StringFormat());


                string clubString = club.Name;
                while (ev.Graphics.MeasureString(clubString, printCompetitorFont).Width > (colResult - colClub))
                {
                    clubString = clubString.Substring(0, clubString.Length - 1);
                }
                ev.Graphics.DrawString(clubString,
                                       printCompetitorFont, Brushes.Black, colClub, yPos, new StringFormat());

                switch (CompetitionType)
                {
                case Structs.CompetitionTypeEnum.Field:
                    printCompetitorField(comp, ref ev, ref yPos);
                    break;

                case Structs.CompetitionTypeEnum.MagnumField:
                    printCompetitorMagnumField(comp, ref ev, ref yPos);
                    break;

                case Structs.CompetitionTypeEnum.Precision:
                    printCompetitorPrecision(comp, ref ev, ref yPos);
                    break;

                default:
                    throw new ApplicationException("Unknown CompetitionType");
                }
            }
        }
コード例 #7
0
        private void printThisCompetitor(PrintPageEventArgs ev,
                                         Structs.Competitor comp, ref float yPos)
        {
            Structs.Shooter shooter = CommonCode.GetShooter(comp.ShooterId);
            Structs.Club    club    = CommonCode.GetClub(shooter.ClubId);
            Structs.Weapon  weapon  = CommonCode.GetWeapon(comp.WeaponId);

            // Print name
            string shooterName = shooter.Surname + " " + shooter.Givenname +
                                 ", " + club.Name;

            ev.Graphics.DrawString(shooterName,
                                   printCompetitorFont, Brushes.Black, placeNameX, yPos,
                                   new StringFormat());

            // Print Club

            /*ev.Graphics.DrawString(club.Name,
             *      printCompetitorFont, Brushes.Black, placeClubX, yPos,
             *      new StringFormat());*/

            // Print weaponsgroup
            ev.Graphics.DrawString(weapon.WClass.ToString(),
                                   printCompetitorFont, Brushes.Black, placeLeftHeaderX, yPos + 2 * printCompetitorFont.Height,
                                   new StringFormat());

            // Print shooterclass
            Structs.ShootersClassShort sclassshort = (Structs.ShootersClassShort)
                                                         (int) comp.ShooterClass;
            ev.Graphics.DrawString(sclassshort.ToString(),
                                   printCompetitorFont, Brushes.Black, placeLeftHeaderX, yPos + 4 * printCompetitorFont.Height,
                                   new StringFormat());

            // Print weapon
            if (comp.WeaponId.ToLower().IndexOf("unknown") == -1)
            {
                ev.Graphics.DrawString(comp.WeaponId.Replace("Unknown", ""),
                                       printCompetitorFont, Brushes.Black, placeLeftHeaderX, yPos + 6 * printCompetitorFont.Height,
                                       new StringFormat());
            }

            // Draw "arrived" checkbox
            float size   = printCompetitorFont.Height;
            float left   = placeNameX + ev.Graphics.MeasureString(shooterName, printCompetitorFont).Width + 10;
            float height = yPos;

            ev.Graphics.DrawString("Ankommit",
                                   printCompetitorFont, Brushes.Black, left + size, height,
                                   new StringFormat());
            Pen pen = new Pen(Brushes.Black, 2);

            ev.Graphics.DrawLine(pen, left, height,
                                 left + size, height);
            ev.Graphics.DrawLine(pen, left, height + size,
                                 left + size, height + size);
            ev.Graphics.DrawLine(pen, left, height,
                                 left, height + size);
            ev.Graphics.DrawLine(pen, left + size, height,
                                 left + size, height + size);
            if (shooter.Arrived)
            {
                ev.Graphics.DrawLine(pen, left, height,
                                     left + size, height + size);
                ev.Graphics.DrawLine(pen, left + size, height,
                                     left, height + size);
            }

            printEmptyCompetitor(ev, ref yPos, comp.Lane);
        }
コード例 #8
0
        private void printCompetitor(PrintPageEventArgs ev,
                                     Structs.Competitor competitor,
                                     PrintLabel label)
        {
            Trace.WriteLine("Competitor: " + competitor.CompetitorId);

            ResultsReturn result = CommonCode.ResultsGetCompetitor(competitor);

            float y = label.Y + label.MarginalTop;
            float x = label.X + label.MarginalLeft;

            string shooterClass = getShooterClassString(
                CommonCode.GetCompetitor(result.CompetitorId));

            ev.Graphics.DrawString(
                shooterClass,
                printFont, Brushes.Black,
                x, y, new StringFormat());

            float indent = ev.Graphics.MeasureString("RES", printFont).Width;

            x = x + indent;

            ev.Graphics.DrawString(
                result.ShooterName,
                printFont, Brushes.Black,
                x, y, new StringFormat());
            y += printFont.Height;

            Structs.Club club = CommonCode.GetClub(
                result.ClubId);

            ev.Graphics.DrawString(
                club.Name,
                printFont, Brushes.Black,
                x, y, new StringFormat());
            y += printFont.Height;

            string resultString = "";

            switch (CommonCode.CompetitionCurrent.Type)
            {
            case Structs.CompetitionTypeEnum.Field:
                resultString = getResultStringField(result);
                break;

            case Structs.CompetitionTypeEnum.MagnumField:
                resultString = getResultStringField(result);
                break;

            case Structs.CompetitionTypeEnum.Precision:
                resultString = result.HitsTotal.ToString() + " p";
                break;
            }

            ev.Graphics.DrawString(
                resultString,
                printFont, Brushes.Black,
                x, y, new StringFormat());

            y += printFont.Height;
        }
コード例 #9
0
        private void printHeader(PrintPageEventArgs ev,
                                 Structs.Shooter shooter, ref float yPos)
        {
            int tab = 125;

            // Print RegistrationsInfo
            ev.Graphics.DrawString(
                "WinShooter",
                printAllbergFont, Brushes.Black,
                LeftMargin, ev.PageBounds.Size.Height - 2 * printHeaderFont.GetHeight() - 20, new StringFormat());

            /*ev.Graphics.DrawString("©John Allberg",
             *      printHeaderFont, Brushes.Black, ev.PageBounds.Right-180,
             *      ev.PageBounds.Size.Height -2*printHeaderFont.GetHeight()-20,
             *      new StringFormat());*/

            // Print logo
            System.Drawing.Image image = getLogo();

            ev.Graphics.DrawImage(
                image,
                ev.MarginBounds.Right - image.Width / 4,
                20,
                image.Width / 4,
                image.Height / 4);

            // Print patrol header
            ev.Graphics.DrawString("Tävling: ",
                                   printHeaderFont, Brushes.Black, LeftMargin, yPos,
                                   new StringFormat());
            ev.Graphics.DrawString(CommonCode.GetCompetitions()[0].Name,
                                   printHeaderFont, Brushes.Black, LeftMargin + tab, yPos,
                                   new StringFormat());
            yPos += printHeaderFont.GetHeight();

            ev.Graphics.DrawString("Namn: ",
                                   printHeaderFont, Brushes.Black, LeftMargin, yPos,
                                   new StringFormat());
            ev.Graphics.DrawString(shooter.Surname + " " + shooter.Givenname,
                                   printHeaderFont, Brushes.Black, LeftMargin + tab, yPos,
                                   new StringFormat());
            yPos += printHeaderFont.GetHeight();

            ev.Graphics.DrawString("Skyttekort: ",
                                   printHeaderFont, Brushes.Black, LeftMargin, yPos,
                                   new StringFormat());
            ev.Graphics.DrawString(shooter.CardNr,
                                   printHeaderFont, Brushes.Black, LeftMargin + tab, yPos,
                                   new StringFormat());
            yPos += printHeaderFont.GetHeight();

            ev.Graphics.DrawString("Skytteklubb: ",
                                   printHeaderFont, Brushes.Black, LeftMargin, yPos,
                                   new StringFormat());
            Structs.Club club = CommonCode.GetClub(shooter.ClubId);
            ev.Graphics.DrawString(club.Name,
                                   printHeaderFont, Brushes.Black, LeftMargin + tab, yPos,
                                   new StringFormat());
            yPos += printHeaderFont.GetHeight();
            yPos += printHeaderFont.GetHeight();
            yPos += printHeaderFont.GetHeight();

            ev.Graphics.DrawString("Starttid",
                                   printHeaderFont, Brushes.Black, LeftMargin + tab1, yPos,
                                   new StringFormat());
            ev.Graphics.DrawString("Patrull",
                                   printHeaderFont, Brushes.Black, LeftMargin + tab2, yPos,
                                   new StringFormat());
            ev.Graphics.DrawString("Vapen",
                                   printHeaderFont, Brushes.Black, LeftMargin + tab3, yPos,
                                   new StringFormat());
            yPos += printHeaderFont.GetHeight();
        }
コード例 #10
0
        private void printHeader(PrintPageEventArgs ev, ref float yPos, int tab)
        {
            float leftMargin = 50;

            // Print watermark "Preliminär"
            if (printPrelResults)
            {
                ev.Graphics.RotateTransform(45);

                Font prelFont = new Font("Arial", 90,
                                         System.Drawing.FontStyle.Regular);

                ev.Graphics.DrawString("Preliminärresultat",
                                       prelFont,
                                       Brushes.LightGray,
                                       ev.MarginBounds.Left,
                                       0,
                                       new StringFormat());

                ev.Graphics.RotateTransform(-45);
            }

            // Print logo
            System.Drawing.Image image = getLogo();

            ev.Graphics.DrawImage(
                image,
                ev.MarginBounds.Right - image.Width / 4,
                20,
                image.Width / 4,
                image.Height / 4);

            // Print page header
            ev.Graphics.DrawString("Tävling: ",
                                   printHeaderFont, Brushes.Black, leftMargin, yPos,
                                   new StringFormat());
            ev.Graphics.DrawString(CommonCode.GetCompetitions()[0].Name,
                                   printHeaderFont, Brushes.Black, leftMargin + tab, yPos,
                                   new StringFormat());
            yPos += printHeaderFont.GetHeight();

            ev.Graphics.DrawString("Vapengrupp: ",
                                   printHeaderFont, Brushes.Black, leftMargin, yPos,
                                   new StringFormat());
            ev.Graphics.DrawString(wclass.ToString(),
                                   printHeaderFont, Brushes.Black, leftMargin + tab, yPos,
                                   new StringFormat());
            yPos += printHeaderFont.GetHeight();

            if (this.clubId != null)
            {
                Structs.Club club = CommonCode.GetClub(clubId);
                ev.Graphics.DrawString("Skytteklubb: ",
                                       printHeaderFont, Brushes.Black, leftMargin, yPos,
                                       new StringFormat());

                ev.Graphics.DrawString(club.Name,
                                       printHeaderFont, Brushes.Black, leftMargin + tab, yPos,
                                       new StringFormat());
                yPos += printHeaderFont.GetHeight();
            }
            //

            // Print allberg on bottom
            ev.Graphics.DrawString("Utskriven " + DateTime.Now.ToShortDateString() + " " +
                                   DateTime.Now.ToShortTimeString(),
                                   printAllbergFont, Brushes.Black, ev.PageBounds.Right - 250,
                                   ev.PageBounds.Size.Height - 2 * printHeaderFont.GetHeight() - 20,
                                   new StringFormat());
        }