Exemplo n.º 1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            if (this.data != null)
            {
                switch (this.typeComboBox.SelectedIndex)
                {
                case 0:
                    MaiRPanel1View panel1View = new MaiRPanel1View(this);
                    panel1View.ValueChanged += new MaiRControlValue.ValueChangedHandler(View_ValueChanged);
                    this.data.PanelItems.Add((IMaiRPanel)panel1View);
                    break;

                case 1:
                    MaiRPanel2View panel2View = new MaiRPanel2View(this);
                    panel2View.ValueChanged += new MaiRControlValue.ValueChangedHandler(View_ValueChanged);
                    this.data.PanelItems.Add((IMaiRPanel)panel2View);
                    break;

                case 2:
                    MaiRPanel3View panel3View = new MaiRPanel3View(this);
                    panel3View.ValueChanged += new MaiRControlValue.ValueChangedHandler(View_ValueChanged);
                    this.data.PanelItems.Add((IMaiRPanel)panel3View);
                    break;

                case 3:
                    MaiRPanel4View panel4View = new MaiRPanel4View(this);
                    panel4View.ValueChanged += new MaiRControlValue.ValueChangedHandler(View_ValueChanged);
                    this.data.PanelItems.Add((IMaiRPanel)panel4View);
                    break;
                }
                ShowMaiRPanel(this.data.PanelItems.Count - 1);
                this.changed = true;
                UpdateFormTitle();
            }
        }
Exemplo n.º 2
0
        public MaiRimoconData ConvertXmlToData(MainForm mainForm, MaiRControlValue.ValueChangedHandler handler)
        {
            MaiRimoconData data = new MaiRimoconData();

            if (this.Valid == true)
            {
                XmlNode node = doc.SelectSingleNode("/rimokoninfo/title");
                if (node != null)
                {
                    data.Title = node.InnerText;
                }

                node = doc.SelectSingleNode("/rimokoninfo/description");
                if (node != null)
                {
                    data.Description = node.InnerText;
                }

                XmlNodeList panelNodeList = doc.SelectNodes("/rimokoninfo/panelinfo");
                if (panelNodeList != null)
                {
                    List <IMaiRPanel> panelList = new List <IMaiRPanel>();
                    for (int i = 0; i < panelNodeList.Count; i++)
                    {
                        try
                        {
                            XmlNodeList        buttonNodeList = panelNodeList.Item(i).SelectNodes("buttoninfo");
                            List <IMaiRButton> buttonList     = new List <IMaiRButton>();
                            if (buttonNodeList != null)
                            {
                                for (int j = 0; j < buttonNodeList.Count; j++)
                                {
                                    int            format    = IRFrame.FORMAT_DENKYO;
                                    List <IRFrame> frameList = new List <IRFrame>();
                                    try
                                    {
                                        XmlNodeList frameNodeList = buttonNodeList.Item(j).SelectNodes("irinfo");
                                        if (frameNodeList != null)
                                        {
                                            for (int k = 0; k < frameNodeList.Count; k++)
                                            {
                                                node = frameNodeList.Item(k).SelectSingleNode("format");
                                                if (k == 0)
                                                {
                                                    format = Convert.ToInt32(node.InnerText);
                                                }
                                                int format2 = Convert.ToInt32(node.InnerText);
                                                node = frameNodeList.Item(k).SelectSingleNode("carrierhigh");
                                                int carrierHigh = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("carrierlow");
                                                int carrierLow = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("leaderhigh");
                                                int leaderHigh = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("leaderlow");
                                                int leaderLow = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("pulse0modulation");
                                                int pulse0Modulation = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("pulse0high");
                                                int pulse0High = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("pulse0low");
                                                int pulse0Low = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("pulse1modulation");
                                                int pulse1Modulation = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("pulse1high");
                                                int pulse1High = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("pulse1low");
                                                int pulse1Low = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("stophigh");
                                                int stopHigh = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("stoplow");
                                                int stopLow = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("frameinterval");
                                                int frameInterval = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("repeathigh");
                                                int repeatHigh = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("repeatlow");
                                                int repeatLow = Convert.ToInt32(node.InnerText);

                                                node = frameNodeList.Item(k).SelectSingleNode("data");
                                                List <byte> dataList = new List <byte>();
                                                for (int l = 0; l < node.InnerText.Length; l = l + 2)
                                                {
                                                    byte b = Convert.ToByte(node.InnerText.Substring(l, 2), 16);
                                                    dataList.Add(b);
                                                }

                                                node = frameNodeList.Item(k).SelectSingleNode("len");
                                                int len = Convert.ToInt32(node.InnerText);

                                                if (dataList.Count > 0 && len > 0)
                                                {
                                                    IRFrameParam param = new IRFrameParam(carrierHigh, carrierLow,
                                                                                          leaderHigh, leaderLow,
                                                                                          pulse0Modulation, pulse0High, pulse0Low,
                                                                                          pulse1Modulation, pulse1High, pulse1Low,
                                                                                          stopHigh, stopLow,
                                                                                          frameInterval,
                                                                                          repeatHigh, repeatLow);
                                                    IRFrameValue value = new IRFrameValue();
                                                    value.ValueList   = dataList;
                                                    value.ValueLength = len;
                                                    IRFrame frame = new IRFrame(format2, param, value);
                                                    frameList.Add(frame);
                                                }
                                            }
                                        }
                                    }
                                    catch
                                    {
                                    }
                                    node = buttonNodeList.Item(j).SelectSingleNode("type");
                                    int buttontype = Convert.ToInt32(node.InnerText);

                                    node = buttonNodeList.Item(j).SelectSingleNode("upperlabel");
                                    String upperlabel = node.InnerText;

                                    node = buttonNodeList.Item(j).SelectSingleNode("innerlabel");
                                    String innerlabel = node.InnerText;

                                    node = buttonNodeList.Item(j).SelectSingleNode("color");
                                    int color = Convert.ToInt32(node.InnerText);

                                    node = buttonNodeList.Item(j).SelectSingleNode("longpush");
                                    bool longpush = Convert.ToBoolean(node.InnerText);

                                    node = buttonNodeList.Item(j).SelectSingleNode("disable");
                                    bool disable = Convert.ToBoolean(node.InnerText);

                                    MaiRButtonView buttonView = new MaiRButtonView();
                                    switch (buttontype)
                                    {
                                    case (int)MaiRControlValue.ButtonType.Type1:
                                        buttonView.Type = MaiRControlValue.ButtonType.Type1;
                                        break;

                                    case (int)MaiRControlValue.ButtonType.Type2:
                                        buttonView.Type = MaiRControlValue.ButtonType.Type2;
                                        break;

                                    case (int)MaiRControlValue.ButtonType.Type3:
                                        buttonView.Type = MaiRControlValue.ButtonType.Type3;
                                        break;
                                    }
                                    buttonView.UpperLabel = upperlabel;
                                    buttonView.InnerLabel = innerlabel;
                                    switch (color)
                                    {
                                    case (int)MaiRControlValue.ButtonColor.Default:
                                        buttonView.Color = MaiRControlValue.ButtonColor.Default;
                                        break;

                                    case (int)MaiRControlValue.ButtonColor.Blue:
                                        buttonView.Color = MaiRControlValue.ButtonColor.Blue;
                                        break;

                                    case (int)MaiRControlValue.ButtonColor.Red:
                                        buttonView.Color = MaiRControlValue.ButtonColor.Red;
                                        break;

                                    case (int)MaiRControlValue.ButtonColor.Green:
                                        buttonView.Color = MaiRControlValue.ButtonColor.Green;
                                        break;

                                    case (int)MaiRControlValue.ButtonColor.Yellow:
                                        buttonView.Color = MaiRControlValue.ButtonColor.Yellow;
                                        break;
                                    }
                                    buttonView.LongPush = longpush;
                                    buttonView.Disable  = disable;
                                    buttonView.Frames   = frameList;

                                    buttonList.Add(buttonView);
                                }
                            }
                            node = panelNodeList.Item(i).SelectSingleNode("title");
                            String title = node.InnerText;
                            node = panelNodeList.Item(i).SelectSingleNode("type");
                            int paneltype = Convert.ToInt32(node.InnerText);
                            switch (paneltype)
                            {
                            case (int)MaiRControlValue.PanelType.Type1:
                                MaiRPanel1View panel1view = new MaiRPanel1View(mainForm);
                                panel1view.Title         = title;
                                panel1view.ButtonItems   = buttonList;
                                panel1view.ValueChanged += handler;
                                panelList.Add(panel1view);
                                break;

                            case (int)MaiRControlValue.PanelType.Type2:
                                MaiRPanel2View panel2view = new MaiRPanel2View(mainForm);
                                panel2view.Title         = title;
                                panel2view.ButtonItems   = buttonList;
                                panel2view.ValueChanged += handler;
                                panelList.Add(panel2view);
                                break;

                            case (int)MaiRControlValue.PanelType.Type3:
                                MaiRPanel3View panel3view = new MaiRPanel3View(mainForm);
                                panel3view.Title         = title;
                                panel3view.ButtonItems   = buttonList;
                                panel3view.ValueChanged += handler;
                                panelList.Add(panel3view);
                                break;

                            case (int)MaiRControlValue.PanelType.Type4:
                                MaiRPanel4View panel4view = new MaiRPanel4View(mainForm);
                                panel4view.Title         = title;
                                panel4view.ButtonItems   = buttonList;
                                panel4view.ValueChanged += handler;
                                panelList.Add(panel4view);
                                break;
                            }
                        }
                        catch
                        {
                        }
                    }
                    data.PanelItems = panelList;
                }
            }
            return(data);
        }