Beispiel #1
0
    public bool BeginRename(string name, int userData, float delay)
    {
        if (m_IsRenaming)
        {
            Debug.LogError("BeginRename fail: already renaming");
            return(false);
        }

        m_Name               = name;
        m_OriginalName       = name;
        m_UserData           = userData;
        m_UserAcceptedRename = false;
        m_IsWaitingForDelay  = delay > 0.0;
        m_IsRenaming         = true;
        m_EditFieldRect      = new Rect(0.0f, 0.0f, 0.0f, 0.0f);
        m_ClientGUIView      = GUIViewWrap.current;
        if (delay > 0.0)
        {
            m_DelayedCallback = new DelayedCallback(BeginRenameInternalCallback, delay);
        }
        else
        {
            BeginRenameInternalCallback();
        }
        return(true);
    }
        public void Dispose()
        {
            _configManager.RemovePropertyChangeListener(OnEvent_ConfigManager_PositionChange);

            var chatLocation = _overlay.Location;

            _configManager.SetProperty("behaviour.frame.chat.position.x", chatLocation.X);
            _configManager.SetProperty("behaviour.frame.chat.position.y", chatLocation.Y);

            var chatSize = _overlay.Size;

            _configManager.SetProperty("behaviour.frame.chat.size.width", chatSize.Width);
            _configManager.SetProperty("behaviour.frame.chat.size.height", chatSize.Height);

            _manager.UISynchronizer.RunSync(() => _overlay.Close());

            _manager.DisposeUIElement(OverlayUIId);
            _moveCallback.Dispose();
            _resizeCallback.Dispose();

            _manager        = null;
            _overlay        = null;
            _configManager  = null;
            _moveCallback   = null;
            _resizeCallback = null;
        }
Beispiel #3
0
        void OpenDocument(string path)
        {
            StatusTextBox.Text += "Opening document: " + path + "\r\n";

            DelayedCallback.Schedule(OpenDocumentDelayed, path);             // schedule callback

            return;
        }
Beispiel #4
0
        /// <summary>
        /// Callback for Rt-click picked up by Windows MessageFilter
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>

        private bool BrowserControlRightMouseButtonMessageReceived(int msg)
        {
            if (msg == WindowsMessage.WM_RBUTTONUP)                                  // show menu on button up
            {
                DelayedCallback.Schedule(ShowKekuleJsBrowserContextMenu, null, 200); // schedule callback, need 200 ms to keep Spotfire selection rectangle from appearing
            }
            return(true);                                                            // say handled if down or up
        }
Beispiel #5
0
 public void ApiLogMessage(string msg)
 {
     if (!msg.EndsWith("\n"))
     {
         msg += "\r\n";
     }
     SpotfireApiLog.Text += msg;
     DelayedCallback.Schedule(ScrollToBottomOfText);
 }
Beispiel #6
0
        private void QuerySelectorDialog_Activated(object sender, EventArgs e)
        {
            ActivationCount++;

            if (ActivationCount == 1)             // show menu on first activation only
            {
                DelayedCallback.Schedule(         // schedule callback
                    delegate(object state)
                    { QuerySelectorControl.ShowSelectQueryMenu(); });
            }
        }
Beispiel #7
0
        private void Criteria_MouseDown(object sender, MouseEventArgs e)
        {
            int ci = GetEditStructureIndex(e.Location);

            if (ci < 0)
            {
                return;
            }

            DelayedCallback.Schedule(DelayedEditMolecule, ci);
        }
Beispiel #8
0
        private int Add(DelayedCallback newCallback)
        {
            // ASSERT: in lock

            var index = _callbacks.BinarySearch(newCallback, newCallback);

            if (index < 0)
            {
                index = ~index;
            }

            _callbacks.Insert(index, newCallback);

            return(index);
        }
Beispiel #9
0
        public void Schedule(Action callback, TimeSpan delay)
        {
            var when        = UtcNow + delay;
            var newCallback = new DelayedCallback {
                CallbackTime = when, Callback = callback
            };

            List <DelayedCallback> elapsed = new List <DelayedCallback>();

            lock (_callbacks)
            {
                if (Add(newCallback) == 0)
                {
                    ResetTimer(elapsed);
                }
            }

            CallCallbacks(elapsed);
        }
Beispiel #10
0
            public int CompareTo(object obj)
            {
                DelayedCallback toCompare = obj as DelayedCallback;

                if (obj == null)
                {
                    return(1);
                }

                if (callTime > toCompare.callTime)
                {
                    return(1);
                }
                else if (callTime < toCompare.callTime)
                {
                    return(-1);
                }

                return(0);
            }
Beispiel #11
0
        public void WaitForTyping(Action callback)
        {
            var when           = UtcNow + TimeSpan.FromMilliseconds(300);
            var typingCallback = new Action(TypingElapsed);
            var newCallback    = new DelayedCallback {
                CallbackTime = when, Callback = typingCallback
            };

            List <DelayedCallback> elapsed = new List <DelayedCallback>();

            lock (_callbacks)
            {
                _typingCallback = callback;

                Remove(typingCallback);
                if (Add(newCallback) == 0)
                {
                    ResetTimer(elapsed);
                }
            }

            CallCallbacks(elapsed);
        }
Beispiel #12
0
        /// <summary>
        /// Look for a parent QueryResultsControl and see if the EditQueryButtonClicked method is defined and call it if so
        /// </summary>
        /// <param name="ctl"></param>
        /// <returns></returns>

        public static bool TryCallCustomExitingQueryResultsCallback(
            Control ctl,
            ExitingQueryResultsType exitType)
        {
            QueryResultsControl qrc;

            ExitingQueryResultsDelegate callback = GetCustomExitingQueryResultsCallback(ctl, out qrc, true);

            if (callback == null)
            {
                return(false);
            }

            ExitingQueryResultsParms p = new ExitingQueryResultsParms();

            p.Qrc      = qrc;
            p.ExitType = exitType;

            object[] arg = new object[] { callback, p };
            DelayedCallback.Schedule(CallCustomExitingQueryResultsCallback, arg);             // call after return from this event

            return(true);
        }
Beispiel #13
0
        private void CommandLineControl_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (e.Button.Kind == ButtonPredefines.Search)
            {
                if (QuickSearchPopup != null)
                {
                    QuickSearchPopup.ExecuteCommandLine();
                }

                CommandLineControl.Focus();
            }

            else if (e.Button.Kind == ButtonPredefines.Combo)
            {
                CommandLineControl.ShowPopup();
            }

            else             // delete/clear text & close popup
            {
                DelayedCallback.Schedule(ResetTreeAndCommandLine);
            }

            return;
        }
Beispiel #14
0
 private void BrowserControlRightMouseClickOccured(object sender, EventArgs e)
 {
     DelayedCallback.Schedule(ShowVisContextMenu, e, 200);             // schedule callback
     return;
 }
Beispiel #15
0
        private void ColGridView_MouseDown(object sender, MouseEventArgs e)
        {
            Point     p;
            Rectangle rect;
            string    txt;
            int       qtCi, ri, ci;

            if (View == null)
            {
                return;
            }
            p = new Point(e.X, e.Y);
            GridHitInfo ghi = View.CalcHitInfo(p);

            if (ghi == null)
            {
                return;
            }
            ri = ghi.RowHandle;

            if (ghi.Column == null)
            {
                return;
            }
            GridColumn gc = ghi.Column;

            GridViewInfo viewInfo = View.GetViewInfo() as GridViewInfo;
            GridCellInfo gci      = viewInfo.GetGridCellInfo(ghi);

            if (gci == null)
            {
                return;
            }

            ri = ghi.RowHandle;
            if (ri == GridControl.NewItemRowHandle)             // click in virtual new row?
            {
                DataRow dr = ColGridDataTable.NewRow();
                ColGridDataTable.Rows.Add(dr);

                DelayedCallback.Schedule(ClickedInNewRow, gc);                 // schedule callback for after grid rendered with new row
                return;
            }

            if (ri >= ColGridDataTable.Rows.Count)
            {
                return;
            }

            CurrentRow = ri;

            if (Lex.Eq(gc.Name, "CustomFormat"))             // Show format col
            {
                MetaColumn mc = GetMetaColumnFromColGridDataTableRow(ColGridDataTable.Rows[ri]);
                if (mc == null)
                {
                    return;
                }

                ColumnFormattingContextMenu.Show(ColGrid, p);
                this.Refresh();
                return;
            }

            return;
        }
Beispiel #16
0
 private void TableNameDropDown_ArrowButtonClick(object sender, EventArgs e)
 {
     LastDropDownButtonClicked = sender as DropDownButton;
     DelayedCallback.Schedule(ShowSelectTableMenu);
     return;
 }
Beispiel #17
0
        public static ResultsViewType LastAddedViewType = ResultsViewType.Unknown;         // type of view added most recently

        /// <summary>
        /// Tentatively add a new view of the specified type to the current page
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>

        internal static void AddTentativeNewViewDelayed(
            ResultsViewModel viewModel)
        {
            DelayedCallback.Schedule(AddTentativeNewViewCallback, viewModel);             // schedule callback
            return;
        }
Beispiel #18
0
        /// <summary>
        /// Post delayed call-back.
        /// </summary>
        /// <param name="synchronizationContext"><see cref="SynchronizationContext"/>.</param>
        /// <param name="callback">Call-back.</param>
        /// <param name="state">Custom state pass to call-back.</param>
        /// <param name="delayMillis">Delayed time in milliseconds.</param>
        /// <returns>Token of posted delayed call-back.</returns>
        public static object PostDelayed(this SynchronizationContext synchronizationContext, SendOrPostCallback callback, object?state, int delayMillis)
        {
            // setup environment
            if (!DelayedCallbackWatch.IsRunning)
            {
                lock (typeof(SynchronizationContextExtensions))
                {
                    if (!DelayedCallbackWatch.IsRunning)
                    {
                        DelayedCallbackWatch.Start();
                        DelayedCallbackThread.Start();
                    }
                }
            }

            // create delayed call-back
            if (delayMillis < 0)
            {
                delayMillis = 0;
            }
            var readyTime       = DelayedCallbackWatch.ElapsedMilliseconds + delayMillis;
            var delayedCallback = new DelayedCallback(synchronizationContext, callback, state, readyTime);

            // enqueue to list or post directly
            if (delayMillis > 0)
            {
                lock (DelayedCallbackSyncLock)
                {
                    var prevDelayedCallback = (DelayedCallback?)null;
                    var nextDelayedCallback = DelayedCallbackListHead;
                    while (nextDelayedCallback != null)
                    {
                        if (nextDelayedCallback.ReadyTime > readyTime)
                        {
                            break;
                        }
                        prevDelayedCallback = nextDelayedCallback;
                        nextDelayedCallback = nextDelayedCallback.Next;
                    }
                    if (nextDelayedCallback != null)
                    {
                        delayedCallback.Next         = nextDelayedCallback;
                        nextDelayedCallback.Previous = delayedCallback;
                    }
                    if (prevDelayedCallback != null)
                    {
                        prevDelayedCallback.Next = delayedCallback;
                        delayedCallback.Previous = prevDelayedCallback;
                    }
                    else
                    {
                        DelayedCallbackListHead = delayedCallback;
                        Monitor.Pulse(DelayedCallbackSyncLock);
                    }
                }
            }
            else
            {
                synchronizationContext.Post(delayedCallback.CallbackEntry, null);
            }
            return(delayedCallback);
        }
Beispiel #19
0
 private void NewBiopolymerMenuItem_Click(object sender, EventArgs e)
 {
     QueryMolCtl.Molecule = new MoleculeMx(MoleculeFormat.Helm);
     QueryMolCtl.RenderMolecule();
     DelayedCallback.Schedule(QueryMolCtl.EditMolecule);             // invoke editor after returning from this event
 }
Beispiel #20
0
 void OpenEditorWithDelay()
 {
     DelayedCallback.Schedule(OpenEditor);
 }
Beispiel #21
0
		private void GridView_MouseUp(object sender, MouseEventArgs e)
		{
			//ClientLog.Message("GridView_MouseUp");
			DelayedCallback.Schedule(GridView_MouseUp_Callback, e); // schedule callback
		}
Beispiel #22
0
 private void BandedGridView_MouseUp(object sender, MouseEventArgs e)
 {
     //ClientLog.Message("BandedGridView_MouseUp");
     DelayedCallback.Schedule(ShowColumnSelectorMenu);             // handle event in timer to avoid strange mouse behavior
 }
Beispiel #23
0
        /// <summary>
        /// Process the change in the checked result types and display corresponding data
        /// </summary>
        /// <param name="ctl"></param>

        private void CheckedChanged(
            CheckEdit ctl)
        {
            if (InSetup)
            {
                return;
            }

            try
            {
                InSetup = true;

                if (ctl == AllMatches)
                {
                    bool amc = AllMatches.Checked;
                    if (AltForms.Enabled)
                    {
                        AltForms.Checked = amc;
                    }
                    if (MatchedPairs.Enabled)
                    {
                        MatchedPairs.Checked = amc;
                    }
                    if (SimilarStructure.Enabled)
                    {
                        SimilarStructure.Checked = amc;
                    }
                    if (SmallWorld.Enabled)
                    {
                        SmallWorld.Checked = amc;
                    }

                    //if (SmallWorldAvailable) SmallWorld.Checked = AllMatches.Checked;
                    //else SmallWorld.Checked = false;
                }

                else
                {
                    bool allChecked =
                        (AltForms.Checked || !AltForms.Enabled) &&
                        (MatchedPairs.Checked || !MatchedPairs.Enabled) &&
                        (SimilarStructure.Checked || !SimilarStructure.Enabled) &&
                        (SmallWorld.Checked || !SmallWorld.Enabled);

                    //if (SmallWorldAvailable) allChecked = allChecked && SmallWorld.Checked;
                    AllMatches.Checked = allChecked;
                }

                Checkmarks = SerializeCheckmarks();         // save current settings

                MatchCountsPanel.Refresh();                 // redraw the counts grid

                if (RenderSearchResultsDelegate != null)
                {
                    DelayedCallback.Schedule(RenderSearchResultsDelegate);
                }

                return;
            }

            catch (Exception ex) { ex = ex; }

            finally { InSetup = false; }
        }
Beispiel #24
0
 void Document_DoubleClick(object sender, EventArgs e)
 {
     DelayedCallback.Schedule(OpenEditor);
 }
Beispiel #25
0
 private void EditStructure_Click(object sender, EventArgs e)
 {
     DelayedCallback.Schedule(QueryMolCtl.EditMolecule);
 }
Beispiel #26
0
        /// <summary>
        /// Tools menu item click
        /// Create a standalone SasMap analysis based on the current query and then run it
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public string Run(
            string args)
        {
            QueryTable  qt;
            MetaTable   mt;
            QueryColumn qc;

            int qid = SS.I.ServicesIniFile.ReadInt("SasMapToolModelQuery", 888070);

            if (qid < 0)
            {
                throw new Exception("SasMapToolModelQuery not defined");
            }

            Query q = QbUtil.ReadQuery(qid);

            if (q == null)
            {
                throw new Exception("Failed to read SasMapToolModelQuery: " + qid);
            }

            q.UserObject = new UserObject(UserObjectType.Query);             // treat this as a new query

            QueryTable sasQt = q.GetQueryTableByNameWithException(SasMapParms.MetaTableName);

            SasQc = sasQt.GetQueryColumnByNameWithException(SasMapParms.ParametersMetaColumnName);

            BaseQuery = GetBaseQuery();
            if (BaseQuery == null || BaseQuery.Tables.Count == 0)
            {
                MessageBoxMx.ShowError("The current query must contain one or more data tables before a SasMap can be defined on the query");
                return("");
            }

            Parms = LastParms;

            qc = BaseQuery?.GetFirstKeyColumn();
            qc = qc.Clone();
            qc.CopyCriteriaFromQueryKeyCriteria(BaseQuery);
            Parms.KeyCriteriaQc = qc;

            Parms.EndpointMc = BaseQuery?.GetFirstResultColumnByPriority(true)?.MetaColumn; // pick the highest priority result column as the default endpoint

            QbUtil.SetMode(QueryMode.Build);                                                // be sure in build mode

            DialogResult dr = Edit();

            if (dr != DialogResult.OK)
            {
                return("");
            }

            StoreParmsInQueryColumnCriteria(Parms, SasQc);

            // Add as a new query and run it

            AnalysisCount++;

            q.Name = "Structure-Activity Similarity Analysis " + AnalysisCount;
            q.SingleStepExecution = true;

            // Add the query to the QueryBuilder and run it

            DelayedCallback.Schedule(             // add and run the query after exiting this dialog
                delegate(object state)
            {
                QbUtil.AddQuery(q);
                QbUtil.SetCurrentQueryInstance(q);                         // set to new query
                QbUtil.RenderQuery();
                QueryExec.RunQuery(q, SS.I.DefaultQueryDest);
            });

            Progress.Hide();

            return("");
        }
        private void InitializeUI()
        {
            _overlay = _manager.CreateUIElement(OverlayUIId, () => new CefOverlayForm());
            _overlay.Show(); //initializes all properties
            _overlay.Visible = false;

            _configManager.AddPropertyChangeListener("behaviour.frame.chat", true, true, OnEvent_ConfigManager_PositionChange);

            _moveCallback = new DelayedCallback(TimeSpan.FromSeconds(1), () =>
            {
                var location = _overlay.Location;
                if (IsFrameOnScreens(_overlay.DesktopBounds))
                {
                    _configManager.SetProperty("behaviour.frame.chat.position.x", location.X);
                    _configManager.SetProperty("behaviour.frame.chat.position.y", location.Y);
                    _configManager.DispatchChangeEvents();
                }
                else // restore last location and size from config
                {
                    UpdateFormPosition();
                }
            });

            _resizeCallback = new DelayedCallback(TimeSpan.FromSeconds(1), () =>
            {
                var size = _overlay.Size;
                if (IsFrameOnScreens(_overlay.DesktopBounds))
                {
                    _configManager.SetProperty("behaviour.frame.chat.size.width", size.Width);
                    _configManager.SetProperty("behaviour.frame.chat.size.height", size.Height);
                    _configManager.DispatchChangeEvents();
                }
                else // restore last location and size from config
                {
                    UpdateFormPosition();
                }
            });

            _overlay.Move        += (s, e) => _moveCallback.Call();
            _overlay.SizeChanged += (s, e) => _resizeCallback.Call();

            _overlay.Browser.OnBrowserLoadPageDone += (s, e) =>
            {
                if (!_overlay.Visible)
                {
                    _manager.UISynchronizer.RunSync(() => _overlay.Visible = true);
                }
            };

            if (_manager.TryGetUIElement <INotifyIconManager>(AppModuleNotifyIcon.NotifyIconManagerId, out var trayIcon))
            {
                //trayIcon.Icon = Gobchat.Resource.GobTrayIconOff;

                trayIcon.OnIconClick += (s, e) => _overlay.Visible = !_overlay.Visible;

                var menuItemHideShow = new ToolStripMenuItem();
                menuItemHideShow.Text    = _overlay.Visible ? Resources.Module_NotifyIcon_UI_Hide : Resources.Module_NotifyIcon_UI_Show;
                menuItemHideShow.Click  += (s, e) => _overlay.Visible = !_overlay.Visible;
                _overlay.VisibleChanged += (s, e) => menuItemHideShow.Text = _overlay.Visible ? Resources.Module_NotifyIcon_UI_Hide : Resources.Module_NotifyIcon_UI_Show;
                trayIcon.AddMenu("overlay.showhide", menuItemHideShow);

                var menuItemReload = new ToolStripMenuItem(Resources.Module_NotifyIcon_UI_Reload);
                menuItemReload.Click += (s, e) => _overlay.Reload();
                trayIcon.AddMenu("overlay.reload", menuItemReload);

                var menuItemFrameReset = new ToolStripMenuItem(Resources.Module_NotifyIcon_UI_Reset);
                menuItemFrameReset.Click += (s, e) => ResetFrameToDefaultLocation();
                trayIcon.AddMenu("overlay.reset", menuItemFrameReset);

#if DEBUG
                var menuItemDevTool = new ToolStripMenuItem("DevTool");
                menuItemDevTool.Click += (s, e) => _overlay.Browser.ShowDevTools();
                trayIcon.AddMenuToGroup("debug", "overlay.devtool", menuItemDevTool);
#endif
            }

            _overlay.Visible = false;
        }
Beispiel #28
0
 private void EditStructure_Click(object sender, EventArgs e)
 {
     DelayedCallback.Schedule(QueryMolCtl.EditMolecule);             // invoke editor after returning from this event
 }
Beispiel #29
0
        /// <summary>
        /// This event occurs when the UIMisc form is shown to do modal structure editing.
        /// We activate Draw & the EditorReturned event ends the dialog
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void MoleculeEditor_Shown(object sender, EventArgs e)
        {
            DelayedCallback.Schedule(Call_KekuleJs_EditStructure);             // delay so this form has time to render and we exit event
        }