Ejemplo n.º 1
0
        public TapeManager(ListBox listBox)
        {
            this.listBox = listBox;

            this.contextMenuStrip        = new ContextMenuStrip();
            this.toolStripMenuItemLoadA  = new ToolStripMenuItem();
            this.toolStripMenuItemLoadB  = new ToolStripMenuItem();
            this.toolStripMenuItemEdit   = new ToolStripMenuItem();
            this.toolStripMenuItemDelete = new ToolStripMenuItem();

            normalFont = new Font(contextMenuStrip.Font, FontStyle.Regular);
            boldFont   = new Font(contextMenuStrip.Font, FontStyle.Bold);

            this.contextMenuStrip.Items.AddRange(new ToolStripItem[] {
                this.toolStripMenuItemLoadA,
                this.toolStripMenuItemLoadB,
                this.toolStripMenuItemEdit,
                this.toolStripMenuItemDelete
            });
            this.toolStripMenuItemLoadA.Text    = "Load Side A";
            this.toolStripMenuItemLoadA.Click  += ToolStripMenuItemLoadA_Click;
            this.toolStripMenuItemLoadB.Text    = "Load Side B";
            this.toolStripMenuItemLoadB.Click  += ToolStripMenuItemLoadB_Click;
            this.toolStripMenuItemEdit.Text     = "Edit";
            this.toolStripMenuItemEdit.Click   += ToolStripMenuItemEdit_Click;
            this.toolStripMenuItemDelete.Text   = "Delete";
            this.toolStripMenuItemDelete.Click += ToolStripMenuItemDelete_Click;

            DpiScaler scaler = new DpiScaler();

            this.listBox.DrawMode          = DrawMode.OwnerDrawFixed;
            this.listBox.ItemHeight        = scaler.S(50);
            this.listBox.DrawItem         += listBox_DrawItem;
            this.listBox.MouseDoubleClick += listBox_MouseDoubleClick;
            this.listBox.MouseDown        += listBox_MouseDown;

            listOfTapes = TapeList.Load(TapeListFile);
            this.listBox.Items.AddRange(listOfTapes.Tapes.ToArray());
        }
Ejemplo n.º 2
0
        public static TapeList Load(string path)
        {
            TapeList listOfTapes = new TapeList();

            if (File.Exists(path))
            {
                var serializer = new XmlSerializer(typeof(TapeList));
                using (var stream = new FileStream(path, FileMode.Open))
                {
                    var obj = serializer.Deserialize(stream);

                    listOfTapes = (TapeList)obj;
                }
            }

            foreach (Tape t in listOfTapes.Tapes)
            {
                t.SideA.Parent = t;
                t.SideB.Parent = t;
            }

            return(listOfTapes);
        }