Пример #1
0
        static void RefreshSendList(object sender, MessageTranferEventArgs e)
        {
            frmControler frm = (frmControler)e.Form;

            if (frm.lstSend.InvokeRequired)
            {
                var d = new SafeCallDelegate(RefreshSendList);
                frm.lstSend.Invoke(d, new object[] { sender, e });
            }
            else
            {
                Console.WriteLine("Copying Queue to send-list...");
                frm.lstSend.Items.Clear();

                QueueMessage[] arr = e.Queue.Waiting_Commands();

                foreach (QueueMessage msg in arr)
                {
                    string Id          = msg.Id;
                    string Message     = msg.Message;
                    string Description = msg.Description;
                    string Reply       = msg.Reply;
                    frm.lstSend.Items.Add(Message);
                }
            }
        }
Пример #2
0
        static void UpdateMarantzLevels(object sender, MessageTranferEventArgs e)
        {
            frmControler frm = (frmControler)e.Form;
            Controller   c   = e.Dispatcher.queue;

            c.UpdateMarantzLevels(LevelControllerFactory.lev_ctrls);
        }
Пример #3
0
        static void ResizeAllThumbs(object sender, MessageTranferEventArgs e)
        {
            frmControler frm = (frmControler)e.Form;
            Controller   c   = e.Dispatcher.queue;

            c.ResizeAllThumbs(LevelControllerFactory.lev_ctrls);
        }
Пример #4
0
        static void Connected(object sender, MessageTranferEventArgs e)
        {
            frmControler frm = e.Form;
            Controller   c   = e.Dispatcher.queue;

            c.Command_List   = frm.command_list;
            c.Command_Lookup = frm.command_lookup;

            foreach (string fullpath in c.Command_Lookup.Keys)
            {
                string cmd = c.Command_Lookup[fullpath];
                if (cmd.EndsWith("?"))
                {
                    Console.WriteLine("{0} - {1}", cmd, fullpath);
                }
            }

            c.SetCurrentMarantzLevels(LevelControllerFactory.lev_ctrls, "MV");  // should only need to send "MV?" message
            c.SetCurrentMarantzLevels(LevelControllerFactory.lev_ctrls, "CV");  // reply will be sent to ProcessReceivedMessage

            foreach (string levctrl in frm.levctrls.Keys)
            {
                LevelController lc = frm.levctrls[levctrl];
                Console.WriteLine(String.Format("{0} - {1}", lc.descr, lc.marantz_current_balance));
            }
        }
Пример #5
0
        static void ProcessReceivedMessage(object sender, MessageTranferEventArgs e)
        {
            String       msg      = e.msg.Message; //  SendReceive.Run_Receiver | this.d.Process_Received(tmsg);
            String       desc     = e.msg.Description;
            String       id       = e.msg.Id;
            String       response = e.msg.Reply;
            frmControler frm      = (frmControler)e.Form;
            Controller   c        = e.Dispatcher.queue;

            c.ProcessMarantzLevels(LevelControllerFactory.lev_ctrls, e.msg);
        }
Пример #6
0
        static void ClearSendList(object sender, MessageTranferEventArgs e)
        {
            frmControler frm = (frmControler)e.Form;

            if (frm.lstSend.InvokeRequired)
            {
                var d = new SafeCallDelegate(ClearSendList);
                frm.lstSend.Invoke(d, new object[] { sender, e });
            }
            else
            {
                Console.WriteLine("Clearing send-list...");
                frm.lstSend.Items.Clear();
            }
        }
Пример #7
0
        static void AddToSendList(object sender, MessageTranferEventArgs e)
        {
            frmControler frm = (frmControler)e.Form;

            if (frm.lstSend.InvokeRequired)
            {
                var d = new SafeCallDelegate(AddToSendList);
                frm.lstSend.Invoke(d, new object[] { sender, e });
            }
            else
            {
                Console.WriteLine("Adding command to top of send-list: {0} ({1})", e.msg.Message, e.msg.Description);
                string s = String.Format("{0}  ( {1} )", e.msg.Message, e.msg.Description);
                frm.lstSend.Items.Insert(0, s); // add to top of to-be-sent list
            }
        }
Пример #8
0
        static void AddToReceiveList(object sender, MessageTranferEventArgs e)
        {
            String       s      = e.msg.Message;
            MsgType      msgtyp = e.MessageType;
            frmControler frm    = (frmControler)e.Form;

            if (frm.lstReceive.InvokeRequired)
            {
                var d = new SafeCallDelegate(AddToReceiveList);
                frm.lstReceive.Invoke(d, new object[] { sender, e });
            }
            else
            {
                frm.lstReceive.Items.Add(s);   // add to bottom of received list
                int n = frm.lstReceive.Items.Count - 1;
                frm.lstReceive.Items[n].BackColor = Globs.MsgColors[msgtyp];
            }
        }
Пример #9
0
        static void ShowParameterValues(object sender, MessageTranferEventArgs e)
        {
            frmControler    frm  = (frmControler)e.Form;
            LevelController lc   = (LevelController)e.LC;
            ScrollBar       sbar = lc.sbar;
            TextBox         txt  = lc.txt;

            if (txt.InvokeRequired)
            {
                var d = new SafeCallDelegate(SetSliderLevel);
                txt.Invoke(d, new object[] { sender, e });
            }
            else
            {
                //  if (lc.gui_flags[LevelController.fTxt]) {
                // 100
                // 12.5 >
                // 10.6 <
                if (lc.last_slider_value < -50 || lc.last_slider_value > 100)
                {
                    bool stop_here = true;
                }
                string slider    = lc.is_unknown(lc.last_slider_value) ? "---" : String.Format("{0:00}", lc.last_slider_value);
                string requested = lc.is_unknown(lc.marantz_current_balance) ? "--.-" : String.Format("{0:00.0}", lc.marantz_current_balance);
                if (!lc.is_unknown(lc.balance_adjusted_level))
                {
                    if (lc.marantz_current_balance != lc.balance_adjusted_level)
                    {
                        requested = lc.is_unknown(lc.balance_adjusted_level) ? "--.-" : String.Format("{0:00.0}", lc.balance_adjusted_level);
                    }
                }
                string reported = lc.is_unknown(lc.reported_level) ? "--.-" : String.Format("{0:00.0}", lc.reported_level);
                string s        = String.Format("{0}\r\n{1} >\r\n{2} <", slider, requested, reported);
                txt.Text = s; // s.Replace(".0", "");
                //  txt.Text = lc.last_slider_value.ToString();
                //  }
                lc.gui_flags[LevelController.fTxt] = false;
            }
        }
Пример #10
0
        static void SetSliderLevel(object sender, MessageTranferEventArgs e)
        {
            frmControler    frm  = (frmControler)e.Form;
            LevelController lc   = (LevelController)e.LC;
            ScrollBar       sbar = lc.sbar;
            TextBox         txt  = lc.txt;

            if ((sbar != null) && (lc.gui_flags[LevelController.fMin] || lc.gui_flags[LevelController.fMax] || lc.gui_flags[LevelController.fLev] || lc.gui_flags[LevelController.fResize]))
            {
                if (sbar.InvokeRequired)
                {
                    var d = new SafeCallDelegate(SetSliderLevel);
                    sbar.Invoke(d, new object[] { sender, e });
                }
                else
                {
                    if (lc.gui_flags[LevelController.fMin] || lc.gui_flags[LevelController.fMax] || lc.gui_flags[LevelController.fResize])
                    {
                        // sliders don't return a level between min_level & max_level
                        // they return the top of a page where the page is located between min_level & max_level
                        int minSbar = lc.slider_min_level;
                        int maxSbar = lc.slider_max_level;

                        LevelMapper tmapper = new LevelMapper((double)minSbar, (double)maxSbar, 0.0, ((sbar.Width > sbar.Height) ? (double)sbar.Width : (double)sbar.Height));
                        //  pageSize = tmapper.B_to_intA(1.2 * (double)((sbar.Width > sbar.Height) ? (double)sbar.Height : (double)sbar.Width));

                        int pageSize = tmapper.B_to_intA(30.0);  // level -> slider

                        //  maxSbar = maxSbar + pageSize;  --- let controller take care of fact that max value is (max -  pagesize)
                        Console.WriteLine("Scroll-bar: length = {0}  => 30 =>  pageSize = {1}", ((sbar.Width > sbar.Height) ? (double)sbar.Width : (double)sbar.Height), pageSize);

                        sbar.LargeChange = pageSize;
                        sbar.Minimum     = minSbar;
                        sbar.Maximum     = maxSbar;

                        //  if (lc.gui_flags[LevelController.fLev]) {
                        //     sbar.Value = lc.last_slider_value; // load_slider_parms is going to trash last_slider_value !!!
                        //  }

                        lc.load_slider_parms(); // corrects last_slider_value based on new pageSize
                    }
                    if (lc.gui_flags[LevelController.fMin])
                    {
                    }
                    if (lc.gui_flags[LevelController.fMax])
                    {
                    }
                    if (lc.gui_flags[LevelController.fLev])
                    {
                        sbar.Value = lc.last_slider_value;
                    }
                }
            }
            if ((txt != null) && lc.gui_flags[LevelController.fTxt])
            {
                ShowParameterValues(sender, e);
            }
            if (sbar != null)
            {
                if (sbar.Value != lc.last_slider_value)
                {
                    Console.WriteLine("Slider level doesn't match slider position: {0} <> {1}", lc.last_slider_value, sbar.Value);
                }
            }
            lc.gui_flags[LevelController.fMin]    = false;
            lc.gui_flags[LevelController.fMax]    = false;
            lc.gui_flags[LevelController.fLev]    = false;
            lc.gui_flags[LevelController.fTxt]    = false;
            lc.gui_flags[LevelController.fResize] = false;
        }