Beispiel #1
0
/// <summary>
/// Start retieval of requested depiction type list for the supplied hitlist
/// </summary>
/// <param name="qc"></param>
/// <param name="color"></param>
/// <param name="align"></param>
/// <param name="getAdditionalDataDelegate"></param>

        public void StartDepictionRetrieval(
            QueryManager qm,
            QueryColumn qc,
            bool color,
            bool align)
        {
            int i = SmallWorldData.GetSvgOptionsIndex(color, align);

            if (Status[i] != 0)
            {
                return;                             // just return if already requested
            }
            string mcName  = qc.MetaColumn.MetaTableDotMetaColumnName;
            string command = "GetDepictions " + mcName + " " + color + " " + align;

            QeGetAdditionalDataDelegate gadd = new QeGetAdditionalDataDelegate(qm.QueryEngine.GetAdditionalData);

            DepictionRetrievalArgs a = new DepictionRetrievalArgs();

            a.qm        = qm;
            a.qc        = qc;
            a.color     = color;
            a.align     = align;
            a.reqId     = ++CurrentRequestId;
            a.startTime = DateTime.Now;

            Status[i] = a.reqId;             // indicate requested

            if (Debug)
            {
                DebugLog.Message("StartDepictionRetrieval " + CurrentRequestId + ", Mc " + mcName + ", Hilight " + color + ", Align " + align);
            }
            gadd.BeginInvoke(command, new AsyncCallback(DepictionRetrievalComplete), a);
            return;
        }
Beispiel #2
0
/// <summary>
/// Retrieval complete. Update cache and request display of values
/// </summary>
/// <param name="r"></param>

        void DepictionRetrievalComplete(IAsyncResult r)
        {
            try
            {
                QeGetAdditionalDataDelegate d = (r as AsyncResult).AsyncDelegate as QeGetAdditionalDataDelegate;

                DepictionRetrievalArgs a = r.AsyncState as DepictionRetrievalArgs;
                int i = SmallWorldData.GetSvgOptionsIndex(a.color, a.align);
                Status[i] = -Status[i];                 // set to negative to indicate complete

                string depictionsListString = d.EndInvoke(r) as string;
                SvgDict[i] = Deserialize(depictionsListString);
                int count = SvgDict[i].Count;

                if (Debug)
                {
                    DebugLog.Message("DepictionRetrievalComplete " + a.reqId + ", Current: " + (a.reqId == CurrentRequestId) +
                                     ", Count: " + count + ", Time: " + LogFile.FormatElapsedTimeInMs(a.startTime));
                }

                if (a.reqId == CurrentRequestId)                 // if latest request then display
                {
                    QueryManager        qm   = a.qm;
                    MoleculeGridControl grid = qm.MoleculeGrid;

                    if (grid.InvokeRequired)                     // use invoke if not on UI thread
                    {
                        grid.Invoke(new MethodInvoker(grid.RefreshDataSourceMx));
                    }

                    else
                    {
                        grid.RefreshDataSourceMx();
                    }
                }
            }
            catch (Exception ex)
            {
                DebugLog.Message("DepictionRetrievalComplete exception: " + DebugLog.FormatExceptionMessage(ex));
            }
        }