Beispiel #1
0
 public ServerService()
 {
     service = new UploadServiceClient();
     service.PublishDocumentCompleted += new EventHandler <PublishDocumentCompletedEventArgs>(service_PublishDocumentCompleted);
     progressBar = new ProgressBarDlg();
     progressBar.SetMax(100);
 }
Beispiel #2
0
        private void buttonBuildLUT_Click(object sender, EventArgs e)
        {
            if (beadCenterPosList.Count == 0)
            {
                MessageBox.Show("No beads selected");
                return;
            }

            CheckBeadPos();

            var dlg = new ProgressBarDlg();

            dlg.Show(new Action(delegate
            {
                using (QTrkInstance inst = new QTrkInstance(settings.trackerConfig))
                {
                    inst.SetRadialZLUTSize(beadCenterPosList.Count, numLUTSteps);
                    inst.BeginLUT(true);

                    int roi = settings.ROI;
                    using (FloatImg tmp = new FloatImg(roi, roi * beadCenterPosList.Count))
                    {
                        for (int i = 0; i < numLUTSteps; i++)
                        {
                            string path = lutFiles[i];
                            if (!File.Exists(path))
                            {
                                MessageBox.Show("File " + path + " missing");
                                break;
                            }
                            dlg.Update(i / (float)numLUTSteps, path, string.Format("Processing LUT Frame {0}/{1}", i, numLUTSteps));
                            using (Bitmap bmp = new Bitmap(path))
                            {
                                if (bmp.Size != imageSize)
                                {
                                    MessageBox.Show(string.Format("{0} has invalid size {1},{2}", path, bmp.Width, bmp.Height));
                                    break;
                                }
                                using (var fi = new FloatImg(bmp, 0))
                                {
                                    // build one image with all beads
                                    for (int b = 0; b < beadCenterPosList.Count; b++)
                                    {
                                        fi.CopySubimage(tmp, beadCenterPosList[b].x - roi / 2, beadCenterPosList[b].y - roi / 2, 0, roi * b, roi, roi);
                                    }
                                    inst.BuildLUT(tmp, i);
                                }
                            }
                        }
                    }
                    inst.FinalizeLUT();
                    lut = inst.GetRadialZLUT();
                }
            }));
            UpdateFileLists();
            tabControl.SelectedTab = tabPageTrack;
        }
Beispiel #3
0
        /// <summary>
        /// Method for converting a specification.
        /// </summary>
        /// <param name="oldfile"></param>
        /// <param name="newfile"></param>
        public static void ConvertFile(string oldfile, string newfile)
        {
            XmlTextReader xmlIn  = null;
            XmlTextWriter xmlOut = null;

            ProgressBarDlg dlg = new ProgressBarDlg();

            dlg.Text         = "Converting " + oldfile.Substring(oldfile.LastIndexOf("\\") + 1) + "...";
            dlg.OkayPressed += new EventHandler(dlg_OkayPressed);
            dlg.Show();

            try
            {
                FileStream fin = new FileStream(oldfile, FileMode.Open);

                xmlIn             = new XmlTextReader(new StreamReader(fin));
                xmlIn.XmlResolver = null;

                dlg.Minimum = 0;
                dlg.Value   = 0;
                dlg.Maximum = (int)fin.Length;

                FileStream fout = new FileStream(newfile, FileMode.Create);

                xmlOut             = new XmlTextWriter(fout, System.Text.Encoding.UTF8);
                xmlOut.Formatting  = Formatting.Indented;
                xmlOut.Indentation = 2;
                xmlOut.WriteStartDocument();

                bool done = false;
                while (xmlIn.Read() && !dlg.Canceling)
                {
                    done = false;

                    if (xmlIn.NodeType == XmlNodeType.Element)
                    {
                        switch (xmlIn.Name)
                        {
                        case STATIC_TAG:
                            xmlOut.WriteStartElement(CONSTANT_TAG);
                            break;

                        case REFSTRING_TAG:
                            xmlOut.WriteStartElement(NEW_REFVALUE_TAG);
                            break;

                        case REFVALUE_TAG:
                            xmlOut.WriteStartElement(NEW_REFVALUE_TAG);
                            break;

                        case OLD_SELECTION_TYPE:
                            HandleSelectionType(xmlIn, xmlOut);
                            done = true;
                            break;

                        case APPLY_TYPE_TAG:
                            HandleTypeTag(xmlIn, xmlOut);
                            done = true;
                            break;

                        case TYPE_TAG:
                            HandleTypeTag(xmlIn, xmlOut);
                            done = true;
                            break;

                        default:
                            xmlOut.WriteStartElement(xmlIn.Name);
                            break;
                        }

                        if (done)
                        {
                            continue;
                        }

                        bool empty = xmlIn.IsEmptyElement;

                        // write out the attributes of this node
                        if (xmlIn.HasAttributes)
                        {
                            xmlIn.MoveToFirstAttribute();
                            for (int i = 0; i < xmlIn.AttributeCount; i++)
                            {
                                switch (xmlIn.Name)
                                {
                                case VERSION_ATTRIBUTE:
                                    xmlOut.WriteAttributeString(VERSION_ATTRIBUTE, NEW_SPEC_VERSION);
                                    break;

                                default:
                                    xmlOut.WriteAttributeString(xmlIn.Name, xmlIn.Value);
                                    break;
                                }
                                xmlIn.MoveToNextAttribute();
                            }
                        }

                        // we don't get an end element if this is an
                        // empty element
                        if (empty)
                        {
                            xmlOut.WriteEndElement();
                        }
                    }
                    else if (xmlIn.NodeType == XmlNodeType.Text)
                    {
                        xmlOut.WriteString(xmlIn.Value);
                    }
                    else if (xmlIn.NodeType == XmlNodeType.EndElement)
                    {
                        xmlOut.WriteEndElement();
                    }
                    else if (xmlIn.NodeType == XmlNodeType.Comment)
                    {
                        xmlOut.WriteComment(xmlIn.Value);
                    }

                    dlg.Value = (int)fin.Position;
                }

                xmlOut.WriteEndDocument();
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception: " + e.Message);
            }
            finally
            {
                if (xmlIn != null)
                {
                    xmlIn.Close();
                }

                if (xmlOut != null)
                {
                    xmlOut.Close();
                }

                if (dlg.Canceling)
                {
                    File.Delete(newfile);
                    dlg.Dispose();
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Method for converting a specification.
        /// </summary>
        /// <param name="oldfile"></param>
        /// <param name="newfile"></param>
        public static void ConvertFile(string oldfile, string newfile)
        {
            XmlTextReader xmlIn  = null;
            XmlTextWriter xmlOut = null;

            ProgressBarDlg dlg = new ProgressBarDlg();

            dlg.Text         = "Converting " + oldfile.Substring(oldfile.LastIndexOf("\\") + 1) + "...";
            dlg.OkayPressed += new EventHandler(dlg_OkayPressed);
            dlg.Show();

            try
            {
                FileStream fin = new FileStream(oldfile, FileMode.Open);

                xmlIn             = new XmlTextReader(new StreamReader(fin));
                xmlIn.XmlResolver = null;

                dlg.Minimum = 0;
                dlg.Value   = 0;
                dlg.Maximum = (int)fin.Length;

                FileStream fout = new FileStream(newfile, FileMode.Create);

                xmlOut             = new XmlTextWriter(fout, System.Text.Encoding.UTF8);
                xmlOut.Formatting  = Formatting.Indented;
                xmlOut.Indentation = 2;
                xmlOut.WriteStartDocument();

                while (xmlIn.Read() && !dlg.Canceling)
                {
                    if (xmlIn.NodeType == XmlNodeType.Element)
                    {
                        switch (xmlIn.Name)
                        {
                        case MAP_TAG:
                            HandleMap(xmlIn, xmlOut);
                            break;

                        case MINIMUM_TAG:
                            HandleStaticTag(xmlIn, xmlOut);
                            break;

                        case MAXIMUM_TAG:
                            HandleStaticTag(xmlIn, xmlOut);
                            break;

                        case INCREMENT_TAG:
                            HandleStaticTag(xmlIn, xmlOut);
                            break;

                        case AVERAGE_TAG:
                            HandleStaticTag(xmlIn, xmlOut);
                            break;

                        case EQUALS_TAG:
                            HandleStaticTag(xmlIn, xmlOut);
                            break;

                        case GREATERTHAN_TAG:
                            HandleStaticTag(xmlIn, xmlOut);
                            break;

                        case LESSTHAN_TAG:
                            HandleStaticTag(xmlIn, xmlOut);
                            break;

                        case VALUE_LABEL_TAG:
                            xmlOut.WriteStartElement(NEW_VALUE_LABEL_TAG);
                            break;

                        case OLD_ITEMS_TAG:
                            xmlOut.WriteStartElement(ITEM_COUNT_TAG);
                            break;

                        case OLD_SELECTION_TYPE:
                            xmlOut.WriteStartElement(SELECTION_TYPE_TAG);
                            break;

                        case OBJECT_REF_TAG:
                            // this element has been removed
                            break;

                        case VALUE_SPACE_TAG:
                            // this element has been removed
                            break;

                        default:
                            bool empty = xmlIn.IsEmptyElement;
                            xmlOut.WriteStartElement(xmlIn.Name);

                            // write out the attributes of this node
                            if (xmlIn.HasAttributes)
                            {
                                xmlIn.MoveToFirstAttribute();
                                for (int i = 0; i < xmlIn.AttributeCount; i++)
                                {
                                    switch (xmlIn.Name)
                                    {
                                    case ACCESS_ATTRIBUTE:
                                        if (xmlIn.Value == ACCESS_READ_ONLY)
                                        {
                                            xmlOut.WriteAttributeString(ACCESS_ATTRIBUTE, NEW_READ_ONLY);
                                        }
                                        else
                                        {
                                            throw new SpecParseException(xmlIn.LineNumber, ACCESS_ATTRIBUTE + " with unexpected value.");
                                        }
                                        break;

                                    case PREFERRED_ATTRIBUTE:
                                        // this attribute doesn't exist anymore
                                        break;

                                    case VERSION_ATTRIBUTE:
                                        xmlOut.WriteAttributeString(VERSION_ATTRIBUTE, NEW_SPEC_VERSION);
                                        break;

                                    case OLD_TYPE_NAME_ATTR:
                                        xmlOut.WriteAttributeString(TYPE_NAME_ATTRIBUTE, xmlIn.Value);
                                        break;

                                    default:
                                        xmlOut.WriteAttributeString(xmlIn.Name, xmlIn.Value);
                                        break;
                                    }
                                    xmlIn.MoveToNextAttribute();
                                }
                            }

                            // we don't get an end element if this is an
                            // empty element
                            if (empty)
                            {
                                xmlOut.WriteEndElement();
                            }

                            break;
                        }
                    }
                    else if (xmlIn.NodeType == XmlNodeType.Text)
                    {
                        xmlOut.WriteString(xmlIn.Value);
                    }
                    else if (xmlIn.NodeType == XmlNodeType.EndElement)
                    {
                        if (xmlIn.Name != VALUE_SPACE_TAG)
                        {
                            xmlOut.WriteEndElement();
                        }
                    }

                    dlg.Value = (int)fin.Position;
                }

                xmlOut.WriteEndDocument();
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception: " + e.Message);
            }
            finally
            {
                if (xmlIn != null)
                {
                    xmlIn.Close();
                }

                if (xmlOut != null)
                {
                    xmlOut.Close();
                }

                if (dlg.Canceling)
                {
                    File.Delete(newfile);
                    dlg.Dispose();
                }
            }
        }