Exemplo n.º 1
0
void xLightsFrame::SetChannelNamesForRgbModel(wxArrayString& ChNames, wxXmlNode* ModelNode)
{
    ModelClass model;
    model.SetFromXml(ModelNode);
    size_t ChannelNum=model.StartChannel-1;
    size_t NodeCount=model.GetNodeCount();
    wxString FormatSpec = wxT("Ch %d: ")+model.name+wxT(" node %d %c");
    for(size_t i=0; i < NodeCount && ChannelNum+2 < ChNames.Count(); i++)
    {
        for(size_t j=0; j < 3; j++)
        {
            ChNames[ChannelNum] = wxString::Format(FormatSpec,ChannelNum+1,i+1,model.RGBorder[j]);
            ChannelNum++;
        }
    }
}
Exemplo n.º 2
0
void ModelListDialog::OnButton_LayoutClick(wxCommandEvent& event)
{
    int sel=ListBox1->GetSelection();
    if (sel == wxNOT_FOUND)
    {
        wxMessageBox(_("Select an item before clicking the Channel Layout button"));
        return;
    }
    wxXmlNode* ModelNode=(wxXmlNode*)ListBox1->GetClientData(sel);
    ModelClass model;
    model.SetFromXml(ModelNode);
    wxString html=model.ChannelLayoutHtml();

    ChannelLayoutDialog dialog(this);
    dialog.HtmlEasyPrint=HtmlEasyPrint;
    dialog.SetHtmlSource(html);
    dialog.ShowModal();
}
Exemplo n.º 3
0
void ModelListDialog::OnButton_ExportCsvClick(wxCommandEvent& event)
{
#if 0
    model name
    display as
    type of strings
#strings
#nodes
    start channel
    start node = (channel+2)/3;
    my display
    brightness
#endif // 0
    wxLogNull logNo; //kludge: avoid "error 0" message from wxWidgets after new file is written
    wxString filename = wxFileSelector(_("Choose output file"), wxEmptyString, wxEmptyString, wxEmptyString, "Export files (*.csv)|*.csv", wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
//    if (filename.IsEmpty()) retmsg(wxString("Please choose an output file name."));
    if (filename.IsEmpty()) return;

    wxFile f(filename);
//    bool isnew = !wxFile::Exists(filename);
    if (!f.Create(filename, true) || !f.IsOpened()) retmsg(wxString::Format("Unable to create file %s. Error %d\n", filename, f.GetLastError()));
    f.Write(_("Model_name, Display_as, String_type, String_count, Node_count, Start_channel, Start_node, My_display, Brightness+-\n"));

    int first = 0, last = ListBox1->GetCount();
    if (ListBox1->GetSelection() != wxNOT_FOUND) last = 1 + (first = ListBox1->GetSelection());
    for (int i = first; i < last; ++i)
    {
        wxXmlNode* node = (wxXmlNode*)ListBox1->GetClientData(i);
        ModelClass model;
        model.SetFromXml(node);
        wxString stch = node->GetAttribute("StartChannel", wxString::Format("%d?", model.NodeStartChannel(0) + 1)); //NOTE: value coming from model is probably not what is wanted, so show the base ch# instead
        f.Write(wxString::Format("\"%s\", \"%s\", \"%s\", %d, %d, %s, %d, %d, %d\n", model.name, model.GetDisplayAs(), model.GetStringType(), model.GetNodeCount() / model.NodesPerString(), model.GetNodeCount(), stch, /*WRONG:*/ model.NodeStartChannel(0) / model.NodesPerString() + 1, model.MyDisplay, model.ModelBrightness));
//no worky        f.Flush(); //paranoid: write out data in case model loop crashes
    }
    f.Close();
    retmsg(wxString::Format(_("Models exported: %d of %d"), last - first, ListBox1->GetCount()));
}