Пример #1
0
        void c1Schedule1_BeforeGroupHeaderFormat(object sender, C1.Win.C1Schedule.BeforeGroupHeaderFormatEventArgs e)
        {
            Contact owner = e.Group.Owner as Contact;

            if (owner != null)
            {
                TestSchedule.C1NWindDataSet.EmployeesRow row = this.c1NWindDataSet1.Employees.FindByEmployeeID((int)owner.Key[0]);
                if (row != null)
                {
                    string imageName = "photo" + row.EmployeeID + ".bmp";
                    if (!File.Exists(imageName))
                    {
                        // resize and cache image into the working directory
                        using (MemoryStream ms = new MemoryStream(row.Photo, 78, row.Photo.Length - 78))
                        {
                            Bitmap bmp  = Image.FromStream(ms, true) as Bitmap;
                            Bitmap bmp1 = ResizeImage(bmp, 82, 94);
                            bmp1.Save(imageName, System.Drawing.Imaging.ImageFormat.Bmp);
                        }
                    }
                    // use image from file
                    // note, C1Schedule only accepts images from internet (http://..),
                    // application resources (res://..) and local file system (file:///...).
                    e.Html = row.FirstName + " " + row.LastName + "&nbsp;<br><img STYLE='padding-top:1mm' src=file:///" + imageName + "/>";
                }
                if (e.Style.Hot != null)
                {
                    // Hot style is applied to the group header when ScheduleGroupItem is selected.
                    e.Style.Hot.BackColor2 = e.Style.Hot.BorderColor = Color.DarkSlateGray;
                    e.Style.Hot.ForeColor  = Color.WhiteSmoke;
                }
            }
            // uncomment the next line to use rectangular group headers
            // e.TriangleTab = false;
        }
Пример #2
0
        public Form1()
        {
            InitializeComponent();
            // suspend C1Schedule updates while loading data
            c1Schedule1.BeginUpdate();
            // TODO: This line of code loads data into the 'nwindDataSet.Customers' table. You can move, or remove it, as needed.
            this.customersTableAdapter.Fill(this.c1NWindDataSet1.Customers_Multi);
            // TODO: This line of code loads data into the 'nwindDataSet.Statuses' table. You can move, or remove it, as needed.
            this.statusesTableAdapter.Fill(this.c1NWindDataSet1.Statuses);
            // TODO: This line of code loads data into the 'nwindDataSet.Products' table. You can move, or remove it, as needed.
            this.productsTableAdapter.Fill(this.c1NWindDataSet1.Products_Schedule);
            // TODO: This line of code loads data into the 'nwindDataSet.Labels' table. You can move, or remove it, as needed.
            this.labelsTableAdapter.Fill(this.c1NWindDataSet1.Labels);
            // TODO: This line of code loads data into the 'nwindDataSet.Employees' table. You can move, or remove it, as needed.
            this.employeesTableAdapter.Fill(this.c1NWindDataSet1.Employees);
            // TODO: This line of code loads data into the 'nwindDataSet.Categories' table. You can move, or remove it, as needed.
            this.categoriesTableAdapter.Fill(this.c1NWindDataSet1.Categories);
            // TODO: This line of code loads data into the 'nwindDataSet.Appointments' table. You can move, or remove it, as needed.
            this.appointmentsTableAdapter.Fill(this.c1NWindDataSet1.Appointments_Multi);

            // set correct MenuCaption for contacts (Customers)
            foreach (Contact cnt in c1Schedule1.DataStorage.ContactStorage.Contacts)
            {
                TestSchedule.C1NWindDataSet.Customers_MultiRow row = this.c1NWindDataSet1.Customers_Multi.FindByCustomerId((Guid)cnt.Key[0]);
                if (row != null)
                {
                    cnt.MenuCaption = row["CompanyName"].ToString() + " (" + row["ContactName"].ToString() + ")";
                }
            }

            // set correct MenuCaption for owners (Employees)
            foreach (Contact cnt in c1Schedule1.DataStorage.OwnerStorage.Contacts)
            {
                TestSchedule.C1NWindDataSet.EmployeesRow row = this.c1NWindDataSet1.Employees.FindByEmployeeID((int)cnt.Key[0]);
                if (row != null)
                {
                    cnt.MenuCaption = row["FirstName"].ToString() + " " + row["LastName"].ToString();
                }
                lstCalendarOwners.Items.Add(cnt);
            }
            for (int i = 0; i < lstCalendarOwners.Items.Count; i++)
            {
                // check all items
                lstCalendarOwners.SetItemChecked(i, true);
            }
            // resume C1Schedule updates
            c1Schedule1.EndUpdate();

            // preview C1Schedule context menu actions
            c1Schedule1.ContextMenuStrip.MouseClick += new MouseEventHandler(ContextMenuStrip_MouseClick);

            _initialized = true;
        }