예제 #1
0
        public ConnectionScreen(Skin skin)
            : base(skin)
        {
            _Connection = new ConnectionDetails();

              _UseActiveSync = new BigButton(Skin);
              _UseActiveSync.Bounds = new Rectangle(10, 10, ClientSize.Width-20, 32);
              _UseActiveSync.Text = "Use ActiveSync";
              _UseActiveSync.Click += new EventHandler(SelectActiveSync);
              _UseActiveSync.Parent = this;

              _Host = new BigButton(Skin);
              _Host.Bounds = new Rectangle(10, 50, ClientSize.Width-20, 32);
              _Host.FitText("Use WLAN: ", _Connection.Host);
              _Host.Click += new EventHandler(EditHost);
              _Host.Parent = this;

              _Cancel = new BigButton(Skin);
              _Cancel.BackColor = Color.DarkRed;
              _Cancel.Bounds = new Rectangle(10, 290, ClientSize.Width-20, 32);
              _Cancel.Text = "Close";
              _Cancel.Click += new EventHandler(OnCancel);
              _Cancel.Parent = this;
        }
예제 #2
0
파일: Client.cs 프로젝트: dada/theresa
 public void CopyTo(ConnectionDetails target)
 {
     target.UseActiveSync = _UseActiveSync;
       target.Host = _Host;
       target.Port = _Port;
 }
예제 #3
0
파일: Client.cs 프로젝트: dada/theresa
        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;
              }
        }