Пример #1
0
        public bool Load(string filename)
        {
            StreamReader file = new StreamReader(filename);
              string xml = file.ReadToEnd();
              file.Close();
              XmlDocument x = new XmlDocument();
              x.LoadXml(xml);
              foreach(XmlNode n in x.ChildNodes[0].ChildNodes) {

            if(n.NodeType == XmlNodeType.Element) {

              switch(n.Name) {
              case "Layout":
            Master.LoadLayout(n.Attributes["name"].Value);
            break;
              case "Skin":
            Skin skin = new Skin();
            skin.Load(n.Attributes["name"].Value);
            Master.ChangeSkin(skin);
            break;
              case "Controller":
            int id = Convert.ToInt32(n.Attributes["id"].Value);
            int cc = Convert.ToInt32(n.Attributes["cc"].Value);
            int value = Convert.ToInt32(n.Attributes["value"].Value);
            foreach(Control c in Master.Controls) {
              if(c is IMidiController) {
            IMidiController controller = (IMidiController) c;
            if(controller.ID == id) {
              controller.Config.Name = n.Attributes["name"].Value;
              controller.Config.CC = cc;
              controller.Value = value;
              Master.OnControlChange(controller, new EventArgs());
            }
              }
            }
            break;
              }
            }
              }
              return true;
        }
Пример #2
0
        public Client()
        {
            Assembly me = Assembly.GetExecutingAssembly();

              if(System.Environment.OSVersion.Platform != PlatformID.WinCE) {
            Width = 240;
            Height = 320 + 34;
              } else {
            this.WindowState = FormWindowState.Maximized;
            this.FormBorderStyle = FormBorderStyle.None;
            this.ControlBox = false;
            this.Menu = null;
              }

              _MagentaKiller = new ImageAttributes();
              _MagentaKiller.SetColorKey(Color.Magenta, Color.Magenta);

              _CurrentConnection = new ConnectionDetails();
              _CurrentConnection.UseActiveSync = true;

              // load default skin
              _DefaultSkin = new Skin();
              _DefaultSkin.Load("Default");

              // reload last settings
              string layout = "Default";
              string skin = "Default";
              _LastDeviceUsed = 0;
              if(File.Exists(AppPath + "\\Last.xml")) {
            StreamReader file = new StreamReader(AppPath + "\\Last.xml");
            string xml = file.ReadToEnd();
            file.Close();
            XmlDocument x = new XmlDocument();
            x.LoadXml(xml);
            foreach(XmlNode n in x.ChildNodes[0].ChildNodes) {
              if(n.NodeType == XmlNodeType.Element) {
            switch(n.Name) {
            case "Connection":
              _CurrentConnection.UseActiveSync = Convert.ToBoolean(n.Attributes["activesync"].Value);
              _CurrentConnection.Host = n.Attributes["host"].Value;
              _CurrentConnection.Port = Convert.ToInt32(n.Attributes["port"].Value);
              break;
            case "Layout":
              layout = n.Attributes["name"].Value;
              break;
            case "Skin":
              skin = n.Attributes["name"].Value;
              break;
            case "Device":
              _LastDeviceUsed = Convert.ToInt32(n.Attributes["id"].Value);
              break;
            }
              }
            }
              }

              CurrentSkin = new Skin();
              CurrentSkin.Load(skin, _DefaultSkin);

              this.BackColor = CurrentSkin.BackgroundColor;
              this.Text = String.Format("Theresa v{0}.{1}.{2}",
            me.GetName().Version.Major,
            me.GetName().Version.Minor,
            me.GetName().Version.Build
              );
              if(me.GetManifestResourceStream("Theresa.Mae.ico") != null) {
            this.Icon = new Icon(me.GetManifestResourceStream("Theresa.Mae.ico"));
              }

              if(me.GetManifestResourceStream("Theresa.Logo.png") != null) {
            _LogoBitmap = new Bitmap(me.GetManifestResourceStream("Theresa.Logo.png"));
              } else {
            _LogoBitmap = new Bitmap(87, 25);
              }
              _Logo = new Control();
              _Logo.BackColor = CurrentSkin.BackgroundColor;
              _Logo.Bounds = new Rectangle(0, 0, _LogoBitmap.Size.Width, _LogoBitmap.Size.Height);
              _Logo.Paint += new PaintEventHandler(PaintLogo);
              _Logo.Parent = this;

              _Quit = new BigButton(CurrentSkin);
              if(me.GetManifestResourceStream("Theresa.Button-Quit.png") != null) {
            _Quit.Picture = new Bitmap(me.GetManifestResourceStream("Theresa.Button-Quit.png"));
              }
              _Quit.BackColor = Color.DarkRed;
              _Quit.Bounds = new Rectangle(this.ClientSize.Width-25, 0, 24, 24);
              _Quit.Text = "Q";
              _Quit.Click += new EventHandler(OnQuit);
              _Quit.Parent = this;

              _Settings = new BigButton(CurrentSkin);
              if(me.GetManifestResourceStream("Theresa.Button-Configure.png") != null) {
            _Settings.Picture = new Bitmap(me.GetManifestResourceStream("Theresa.Button-Configure.png"));
              }
              _Settings.Bounds = new Rectangle(this.ClientSize.Width-50, 0, 24, 24);
              _Settings.Text = "C";
              _Settings.Click += new EventHandler(OnSettings);
              _Settings.Parent = this;

              _DisplayMode = new BigButton(CurrentSkin);
              if(me.GetManifestResourceStream("Theresa.Button-DisplayMode.png") != null) {
            _DisplayMode.Picture = new Bitmap(me.GetManifestResourceStream("Theresa.Button-DisplayMode.png"));
              }
              _DisplayMode.Bounds = new Rectangle(this.ClientSize.Width-75, 0, 24, 24);
              _DisplayMode.Text = "#";
              _DisplayMode.Click += new EventHandler(OnChangeDisplayMode);
              _DisplayMode.Parent = this;

              _SavePreset = new BigButton(CurrentSkin);
              if(me.GetManifestResourceStream("Theresa.Button-Save.png") != null) {
            _SavePreset.Picture = new Bitmap(me.GetManifestResourceStream("Theresa.Button-Save.png"));
              }
              _SavePreset.Bounds = new Rectangle(this.ClientSize.Width-100, 0, 24, 24);
              _SavePreset.Text = "S";
              _SavePreset.Click += new EventHandler(OnSavePreset);
              _SavePreset.Parent = this;

              _LoadPreset = new BigButton(CurrentSkin);
              if(me.GetManifestResourceStream("Theresa.Button-Quit.png") != null) {
            _LoadPreset.Picture = new Bitmap(me.GetManifestResourceStream("Theresa.Button-Load.png"));
              }
              _LoadPreset.Bounds = new Rectangle(this.ClientSize.Width-125, 0, 24, 24);
              _LoadPreset.Text = "L";
              _LoadPreset.Click += new EventHandler(OnLoadPreset);
              _LoadPreset.Parent = this;

              _TryToConnect = new System.Windows.Forms.Timer();
              _TryToConnect.Tick += new EventHandler(OnTryToConnect);
              _TryToConnect.Interval = 1000;
              _TryToConnect.Enabled = false;

              LoadLayout(layout);
              Connect();

              if(_Connected) {
            CurrentDevice = Devices[_LastDeviceUsed];
              } else {
            _Devices = new MidiDevice[0];
            _CurrentDevice = new MidiDevice();
            _CurrentDevice.ID = 0;
            _CurrentDevice.Name = "none";
            Console.WriteLine("Can't connect");
            // _TryToConnect.Enabled = true;
              }
        }
Пример #3
0
 private void OnChooseSkin(object sender, EventArgs e)
 {
     SelectionScreen select = Global.GetSelectionScreen(Skin);
       select.Items.Clear();
       foreach(string file in Directory.GetFiles(AppPath + "\\Skins")) {
     if(file.ToLower().EndsWith(".xml")) {
       string name = Path.GetFileNameWithoutExtension(file);
       select.Items.Add(name);
     }
       }
       select.ShowPage();
       DialogResult r = select.ShowDialog();
       if(r == DialogResult.OK) {
     Skin skin = new Skin();
     skin.Load(select.Items[select.SelectedIndex].ToString());
     Master.ChangeSkin(skin);
     _ChooseSkin.Text = "Skin: " + Master.CurrentSkin.Name;
       }
 }