Exemplo n.º 1
0
        void set_balance(String controller)
        {
            MultiLevelController mlc = (MultiLevelController)this.levctrls[controller];

            ScrollBar sbar = mlc.sbar;

            int new_lev = Math.Min(mlc.slider_max_level, Math.Max(mlc.slider_min_level, sbar.Value));

            mlc.change_balance(new_lev);

            // compare current val to lastval  .. calculate % increase/descrease
            // increase all left|top marantz volumes by same %
            // decrease all right|bottom marantz volumes by same %
        }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (Globs.NO_SEND)
            {
                this.chkSEND.Checked = false;
            }
            else
            {
                this.chkSEND.Checked = true;
            }
            if (System.IO.File.Exists(Globs.json_file3))
            {
                Load_Tree(Globs.json_file3);
            }
            else if (System.IO.File.Exists(Globs.json_file2))
            {
                Load_Tree(Globs.json_file2);
            }
            else
            {
                Load_Tree(Globs.json_file);
            }

            ShowSliderLevelLegend(this.txtScrollLegend);

            this.d    = new Dispatcher(); // Dispatcher handles events
            this.d.ui = this;

            this.d.MessageSender       += AddToSendList;
            this.d.MessageReceiver     += AddToReceiveList;
            this.d.SendRefresher       += RefreshSendList;
            this.d.SendClearer         += ClearSendList;
            this.d.ConnectNotifier     += Connected;
            this.d.SliderSetter        += SetSliderLevel;
            this.d.ResizeHandler       += SetSliderLevel;
            this.d.ParameterShower     += ShowParameterValues;
            this.d.ReceiveProcessor    += ProcessReceivedMessage;
            this.d.MarantzLevelUpdater += UpdateMarantzLevels;
            this.d.ThumbResizer        += ResizeAllThumbs;

            this.c = new Controller(this.d);

            this.d.queue = this.c;

            this.rz = new Resizer(this.d);

            this.sr           = new SendReceive(this.d); // Connection manages connection to remote host
            this.d.connection = this.sr;

            if (!BACKGROUND_CONNECT)
            {
                if (!sr.Connect(Globs.marantz_host))
                {
                    string err = sr.Errors;
                    return;
                }
            }
            this.send_receive_thread = new System.Threading.Thread(Send_Receive_Thread);

            LevelController      lc;
            MultiLevelController mlc;

            LevelController.Orient vert  = LevelController.Orient.vert;
            LevelController.Orient horiz = LevelController.Orient.horiz;

            // FL = Front-Left
            // FR = Front-Right
            // C  = Center
            // SW = Sub-Woofer
            // SL = Surround-Left
            // SR = Surround-Right
            // SBL = Surround-Back-Left  -> Front-Lower-Half-Left
            // SBR = Surround-Back-Right -> Front-Lower-Half-Right
            // FHL = Front-Height-Left
            // FHR = Front-Height-Right
            // FWL = Front-Width-Left
            // FWR = Front-Width-Right

            lc = LevelControllerFactory.New("Main Volume", "MV", horiz, (ScrollBar)this.zMasterVolume, this.txtMasterVolume, this.d);
            this.levctrls.Add("zMasterVolume", lc);
            lc = LevelControllerFactory.New("Front Left harder|softer", "CVFL", vert, null, this.txtFrontLeft, this.d);
            this.levctrls.Add("zFrontLeft", lc);
            lc = LevelControllerFactory.New("Front Right harder|softer", "CVFR", vert, null, this.txtFrontRight, this.d);
            this.levctrls.Add("zFrontRight", lc);
            lc = LevelControllerFactory.New("Back Left Surround Speaker harder|softer", "CVSL", vert, (ScrollBar)this.zBackLeft, this.txtBackLeft, this.d);
            this.levctrls.Add("zBackLeft", lc);
            lc = LevelControllerFactory.New("Back Right Surround Speaker harder|softer", "CVSR", vert, (ScrollBar)this.zBackRight, this.txtBackRight, this.d);
            this.levctrls.Add("zBackRight", lc);
            lc = LevelControllerFactory.New("Front Left Lower-Half harder|softer", "CVSBL", vert, (ScrollBar)this.zBassLeft, this.txtBassLeft, this.d);
            this.levctrls.Add("zBassLeft", lc);
            lc = LevelControllerFactory.New("Front Right Lower-Half harder|softer", "CVSBR", vert, (ScrollBar)this.zBassRight, this.txtBassRight, this.d);
            this.levctrls.Add("zBassRight", lc);
            lc = LevelControllerFactory.New("Center-Speaker harder|softer", "CVC", vert, (ScrollBar)this.zCenterVolume, this.txtCenterVolume, this.d);
            this.levctrls.Add("zCenterVolume", lc);

            lc = LevelControllerFactory.New("Test Balance Control", "-", horiz, (ScrollBar)this.sbSlider, this.txtSlider, this.d);
            this.levctrls.Add("sbSlider", lc);

            int n = 0;

            mlc = new MultiLevelController("Master L|R Balance",
                                           new string[] { "CVFL", "CVSBL" },  /* left top */
                                           new string[] { "CVFR", "CVSBR" },  /* right top */
                                           new string[] { "CVSL" },           /* left bottom */
                                           new string[] { "CVSR" },           /* right bottom */
                                           horiz, (ScrollBar)this.zMasterBalance, this.txtMasterBalance, this.d);
            foreach (LevelController tlc in mlc.level_controllers())
            {
                this.levctrls.Add(String.Format("L|R {0}", n++), lc);
            }
            this.levctrls.Add("zMasterBalance", mlc);
            this.balance_ctrls.Add("zMasterBalance", mlc);

            //                                                   Back Commands                    Front Commands
            mlc = new MultiLevelController("Front|Back Balance",
                                           new string[] { "CVFL", "CVSBL", "CVC" },  /* left top */
                                           new string[] { "CVFR", "CVSBR", "CVC" },  /* right top */
                                           new string[] { "CVSL" },                  /* left bottom */
                                           new string[] { "CVSR" },                  /* right bottom */
                                           vert, (ScrollBar)this.zBalanceFrontRear, this.txtBalanceFrontRear, this.d);
            foreach (LevelController tlc in mlc.level_controllers())
            {
                this.levctrls.Add(String.Format("F|B {0}", n++), lc);
            }
            this.levctrls.Add("zBalanceFrontRear", mlc);
            this.balance_ctrls.Add("zBalanceFrontRear", mlc);

            //                                                     Left Commands            Right Commands
            mlc = new MultiLevelController("Surround L|R Balance", new string[] { "CVSL" }, new string[] { "CVSR" },
                                           new string[] { }, new string[] { },
                                           horiz, (ScrollBar)this.zRearBalance, this.txtRearBalance, this.d);
            foreach (LevelController tlc in mlc.level_controllers())
            {
                this.levctrls.Add(String.Format("Surr L|R {0}", n++), lc);
            }
            this.levctrls.Add("zRearBalance", mlc);
            this.balance_ctrls.Add("zRearBalance", mlc);

            foreach (string levctrl in this.levctrls.Keys)
            {
                LevelController tlc = this.levctrls[levctrl];
                tlc.balance_controlers = this.balance_ctrls;
            }

            this.d.ResizeAllThumbs();  // need to manually trigger resize so thumbs are the correct size

            this.send_receive_thread.Start(this.sr);

            mlc.test_balance();

            //this.d.Start_Session();  // tell ReceiveThread to expect output from Receiver

            //if (!pr.Go()) {
            //    String errs = pr.Errors;
            //    if (errs == "")
            //        errs = "Unknown Processor Error";
            //    ui.Add_to_Received(errs);
            //}
        }