コード例 #1
0
ファイル: LayoutEditor.cs プロジェクト: 2max968/Kritzelv2
 private void BackgroundSelectPanel1_ItemClicked(GUIElements.BackgroundSelectPanel sender, Type bgrType)
 {
     Backgrounds.Background bgr = (Backgrounds.Background)bgrType.GetConstructor(new Type[0])
                                  .Invoke(new object[0]);
     page.Background = bgr;
     inkControl?.RefreshPage();
 }
コード例 #2
0
ファイル: LayoutEditor.cs プロジェクト: 2max968/Kritzelv2
        private void LvBackgrounds_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvBackgrounds.FocusedItem == null)
            {
                return;
            }
            Type bgrType = (Type)lvBackgrounds.FocusedItem.Tag;

            Backgrounds.Background bgr = (Backgrounds.Background)bgrType.GetConstructor(new Type[0])
                                         .Invoke(new object[0]);
            page.Background = bgr;
            inkControl?.RefreshPage();
        }
コード例 #3
0
ファイル: LayoutEditor.cs プロジェクト: 2max968/Kritzelv2
        void createBackgroundList(Type current)
        {
            Assembly      asm      = Assembly.GetCallingAssembly();
            List <Type>   bgrTypes = new List <Type>();
            List <string> names    = new List <string>();
            List <Bitmap> icons    = new List <Bitmap>();

            bgrTypes.Add(typeof(Backgrounds.BackgroundNull));
            names.Add("None");
            icons.Add(new Bitmap(PSIZE, PSIZE));
            float iconFactor = 1.5f;

            foreach (Type t in asm.GetTypes())
            {
                if (t.IsSubclassOf(typeof(Backgrounds.Background)) &&
                    t.GetCustomAttribute <Backgrounds.BName>() != null)
                {
                    bgrTypes.Add(t);
                    names.Add(t.GetCustomAttribute <Backgrounds.BName>().Name);
                    PageFormat format =
                        new PageFormat(Util.PointToMm(PSIZE) * iconFactor, Util.PointToMm(PSIZE) * iconFactor);
                    Backgrounds.Background bgr =
                        (Backgrounds.Background)t.GetConstructor(new Type[0]).Invoke(new object[0]);
                    Bitmap bmp = new Bitmap(PSIZE, PSIZE);
                    using (Graphics g = Graphics.FromImage(bmp))
                    {
                        g.ScaleTransform(1 / iconFactor, 1 / iconFactor);
                        bgr.Draw(g.GetRenderer(), format,
                                 2, Color.LightGray, Color.Red);
                    }
                    icons.Add(bmp);
                }
            }

            iconlist.ImageSize = new Size(PSIZE, PSIZE);
            iconlist.Images.Clear();
            lvBackgrounds.Items.Clear();
            for (int i = 0; i < names.Count; i++)
            {
                iconlist.Images.Add(icons[i]);
                ListViewItem itm = new ListViewItem(names[i], i);
                itm.Tag = bgrTypes[i];
                lvBackgrounds.Items.Add(itm);
                if (current == bgrTypes[i])
                {
                    lvBackgrounds.FocusedItem = itm;
                }
            }
        }