コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        public bool RegisterOperation(OperationInformation operationInfo, bool assignId)
        {
            if (assignId && string.IsNullOrEmpty(operationInfo.Id) == false)
            {
                SystemMonitor.Warning("Id of operation already assigned.");
                return(false);
            }

            if (assignId)
            {
                operationInfo.Id = GetNextOperationCustomID().ToString();
            }

            lock (this)
            {
                if (_pendingOperations.ContainsKey(operationInfo.Id))
                {
                    SystemMonitor.Error("An operation for this order id already running.");
                    return(false);
                }

                // Register now to be sure, that whenever responce and OrderResponce come they will be handled OK.
                _pendingOperations.Add(operationInfo.Id, operationInfo);
                operationInfo.OperationCompleteEvent += new OperationInformation.OperationUpdateDelegate(operationInfo_OperationCompleteEvent);
            }

            return(true);
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        public virtual void AddItems(NewsItem[] items)
        {
            List <NewsItem> addedItems = new List <NewsItem>();

            lock (this)
            {
                string[] channelsNames = GeneralHelper.EnumerableToArray <string>(ChannelsNames);
                foreach (NewsItem newItem in items)
                {
                    if (channelsNames.Length <= newItem.ChannelId)
                    {
                        SystemMonitor.Warning("Item points to a not available channel.");
                        continue;
                    }

                    string channelName = channelsNames[newItem.ChannelId];

                    //if (_channels[channelName] == false)
                    //{// Channel disabled.
                    //    continue;
                    //}

                    NewsItem existingItem = null;
                    foreach (DateTime time in _channelsItems[channelName].Keys)
                    {// Item may be a repost with another time, so check all time periods.
                        foreach (NewsItem item in _channelsItems[channelName][time])
                        {
                            if (item.CompareTo(newItem) == 0)
                            {// Item already exists.
                                existingItem = item;
                                break;
                            }
                        }

                        if (existingItem != null)
                        {
                            break;
                        }
                    }

                    if (existingItem != null)
                    {
                        continue;
                    }

                    if (_channelsItems[channelName].ContainsKey(newItem.DateTime) == false)
                    {
                        _channelsItems[channelName][newItem.DateTime] = new List <NewsItem>();
                    }

                    _channelsItems[channelName][newItem.DateTime].Add(newItem);
                    addedItems.Add(newItem);
                }
            }

            if (ItemsAddedEvent != null && addedItems.Count > 0)
            {
                ItemsAddedEvent(this, addedItems.AsReadOnly());
            }
        }
コード例 #3
0
        List <AutomatedControlEventHandler> GetControlHandlers(Control control)
        {
            List <AutomatedControlEventHandler> result = new List <AutomatedControlEventHandler>();

            // Check attribute handlers.
            Type[] handlerTypes = AutomatedControlEventHandlerAttribute.GetClassHandlerTypes(control.GetType());
            foreach (Type handlerType in handlerTypes)
            {
                if (_attributeHandlers.ContainsKey(handlerType) == false)
                {
                    object handler = Activator.CreateInstance(handlerType);
                    if (handler == null)
                    {
                        SystemMonitor.Warning("Failed to create, with default constructor, handler of type [" + handlerType.Name + "]");
                        continue;
                    }
                    _attributeHandlers.Add(handlerType, (AutomatedControlEventHandler)handler);
                }
                result.Add(_attributeHandlers[handlerType]);
            }

            // Chech manually assigned handlers.
            foreach (Type type in _controlTypeHandlers.Keys)
            {
                if (control.GetType() == type || control.GetType().IsSubclassOf(type))
                {
                    result.AddRange(_controlTypeHandlers[type]);
                }
            }

            return(result);
        }
コード例 #4
0
        public virtual bool StepToEnd()
        {
            if (StepToEndEvent != null && StepToEndEvent(this) == false)
            {
                return(false);
            }

            foreach (ITimeControl control in SlaveControlsArray)
            {
                if (control.StepToEnd() == false)
                {
                    SystemMonitor.Warning("Slave control has failed to follow master time control.");
                }
            }

            if (TotalStepsCount.HasValue)
            {
                ChangeCurrentStep(TotalStepsCount.Value);
            }
            else
            {
                ChangeCurrentStep(int.MaxValue);
            }
            return(true);
        }
コード例 #5
0
        public void DockControl(DragControl dragControl, DockStyle dockPane)
        {
            if (_dragControls.Contains(dragControl) == false)
            {
                SystemMonitor.Warning("Miuse of method.");
                return;
            }

            ClearControlSplitter(dragControl);

            switch (dockPane)
            {
            case DockStyle.None:
            {        // Floating.
                if (AllowFloating)
                {
                    dragControl.Dock   = DockStyle.None;
                    dragControl.Parent = this;
                    dragControl.BringToFront();
                }
                else
                {
                    AddControlToContainer(panelCenter, dragControl);
                }
            }
            break;

            case DockStyle.Bottom:
                AddControlToContainer(panelBottom, dragControl);
                break;

            case DockStyle.Fill:
                AddControlToContainer(panelCenter, dragControl);
                break;

            case DockStyle.Left:
                AddControlToContainer(panelLeft, dragControl);
                break;

            case DockStyle.Right:
                AddControlToContainer(panelRight, dragControl);
                break;

            case DockStyle.Top:
                AddControlToContainer(panelTop, dragControl);
                break;

            default:
                break;
            }

            UpdatePanels();
        }
コード例 #6
0
        void PersistControlData(CommonBaseControl control, Component containingComponent)
        {
            control.SaveState();

            Point?location = null;
            Size? size     = null;

            if (containingComponent == null)
            {
                return;
            }

            // Since this info will be cleared on next line, store here for reference.
            bool isChecked = control.PersistenceData.ContainsValue("combinedContainer.Checked") &&
                             control.PersistenceData.GetBoolean("combinedContainer.Checked");

            // Clear all previous persistence info related to "combinedContainer".
            control.PersistenceData.ClearByNamePart("combinedContainer.");

            if (containingComponent is ToolStripButton ||
                control == _checkedControl)
            {
                control.PersistenceData.AddValue("combinedContainer.Tabbed", true);
                control.PersistenceData.AddValue("combinedContainer.Checked", isChecked);
                control.PersistenceData.AddValue("combinedContainer.TabIndex", toolStripMain.Items.IndexOf((ToolStripButton)containingComponent));
            }
            else if (containingComponent is CombinedHostingForm)
            {
                location = ((CombinedHostingForm)containingComponent).Location;
                size     = ((CombinedHostingForm)containingComponent).Size;
                control.PersistenceData.AddValue("combinedContainer.Floating", true);
            }
            else if (containingComponent is DragControl)
            {
                control.PersistenceData.AddValue("combinedContainer.Docked", true);
                control.PersistenceData.AddValue("combinedContainer.Guid", ((DragControl)containingComponent).Guid);
            }
            else
            {
                SystemMonitor.Warning("Unrecognized case.");
                return;
            }

            if (location.HasValue)
            {
                control.PersistenceData.AddValue("combinedContainer.Location", location.Value);
            }

            if (size.HasValue)
            {
                control.PersistenceData.AddValue("combinedContainer.Size", size.Value);
            }
        }
コード例 #7
0
        public bool GetItemTypeFiltering(TracerItem.TypeEnum itemType)
        {
            lock (this)
            {
                if (_itemTypes.ContainsKey(itemType))
                {
                    return(_itemTypes[itemType]);
                }
            }

            SystemMonitor.Warning("Unknown item type introduced.");
            return(false);
        }
コード例 #8
0
        //void VirtualListViewEx_TopItemChangeEvent(int i, int item)
        //{
        //    // This causes a bad overdraw flicker, do not uncomment!
        //    //UpdateColumnWidths();
        //}

        //int _lastTopItem = -1;
        //protected override void OnNotifyMessage(Message m)
        //{
        //    lock (this)
        //    {
        //        base.OnNotifyMessage(m);
        //        if (this != null && this.Visible && TopItemChangeEvent != null && m.Msg != 0x1027)
        //        {// TODO : under MONO the message code may be different.

        //            ListViewItem topItem = this.TopItem;

        //            // 1027 is escaped to prevent stack overflows, since call to TopItem causes it.
        //            if (topItem != null && _lastTopItem != topItem.Index)
        //            {
        //                TopItemChangeEvent(topItem.Index, 0);
        //                _lastTopItem = topItem.Index;
        //            }
        //        }
        //    }
        //}

        // Handle this to provide items.
        //protected override void OnRetrieveVirtualItem(RetrieveVirtualItemEventArgs e)
        //{
        //}

        public void UpdateAutoScrollPosition()
        {
            try
            {
                if (VirtualListSize > 5 && _autoScroll)
                {// If we move closer to -1 the list crashes.
                 //EnsureVisible(VirtualListSize - 1);
                }
            }
            catch (Exception ex)
            {
                SystemMonitor.Warning("UI logic error (ListView bug) [" + GeneralHelper.GetExceptionMessage(ex) + "].");
            }
        }
コード例 #9
0
        public void Dispose()
        {
            Stop();

            if (_workerInternalThread != null && _workerInternalThread.ThreadState == ThreadState.Running)
            {
                // Allow a few ms for the thread to try and stop as it should.
                Thread.Sleep(500);

                if (_workerInternalThread.ThreadState == ThreadState.Running)
                {
                    SystemMonitor.Warning("Aborting background message processing thread.");
                    _workerInternalThread.Abort();
                }
            }
        }
コード例 #10
0
        public virtual bool StepTo(int index)
        {
            if (StepToEvent != null && StepToEvent(this, index) == false)
            {
                return(false);
            }

            foreach (ITimeControl control in SlaveControlsArray)
            {
                if (control.StepTo(index) == false)
                {
                    SystemMonitor.Warning("Slave control has failed to follow master time control.");
                }
            }

            ChangeCurrentStep(index);
            return(true);
        }
コード例 #11
0
        /// <summary>
        /// Add a floating control to the workspace area.
        /// location considered only for floating (dockStyle = none)
        /// </summary>
        public DragControl AddWorkspaceControl(CommonBaseControl control, DockStyle dockPane, Point location)
        {
            if (dragContainerControl.GetDragControlFromContainedControl(control) != null)
            {
                SystemMonitor.Warning("Misuse.");
                return(null);
            }

            DragControl dragControl = new DragControl();

            SetControlToDragControl(control, dragControl, location);

            dragContainerControl.AddDragControl(dragControl);
            dragContainerControl.DockControl(dragControl, dockPane);

            UpdateUI();

            return(dragControl);
        }
コード例 #12
0
        public static bool Serialize(MemoryStream stream, object p)
        {
            try
            {
                IFormatter formatter = GenerateFormatter();
                formatter.Serialize(stream, p);
                if (stream.Position > SerializationWarningLimit)
                {
                    SystemMonitor.Warning("Serialialization of object [" + p.GetType().Name + "] has grown above the default serialization limit to [" + stream.Position.ToString() + "] bytes.");
                }

                return(true);
            }
            catch (Exception ex)
            {
                SystemMonitor.Error("Failed to serialize object [" + p.GetType().Name + "," + ex.Message + "].");
                return(false);
            }
        }
コード例 #13
0
        public virtual bool Restart()
        {
            if (CanRestart == false ||
                (RestartEvent != null && RestartEvent(this) == false))
            {
                return(false);
            }

            foreach (ITimeControl control in SlaveControlsArray)
            {
                if (control.Restart() == false)
                {
                    SystemMonitor.Warning("Slave control has failed to follow master time control.");
                }
            }

            ChangeCurrentStep(0);
            return(true);
        }
コード例 #14
0
        public virtual bool StepBack(int steps)
        {
            if (CanStepBack == false ||
                (StepBackEvent != null && StepBackEvent(this, steps) == false))
            {
                return(false);
            }

            foreach (ITimeControl control in SlaveControlsArray)
            {
                if (control.StepBack(steps) == false)
                {
                    SystemMonitor.Warning("Slave control has failed to follow master time control.");
                }
            }

            ChangeCurrentStep(_currentStep - steps);
            return(true);
        }
コード例 #15
0
        void UnRegisterControl(Control control)
        {
            if (_controls.Remove(control) == false)
            {
                SystemMonitor.Warning("Unregistered control type not found [ " + control.Name + "]");
                return;
            }

            control.ControlAdded   -= new ControlEventHandler(control_ControlAdded);
            control.ControlRemoved -= new ControlEventHandler(control_ControlRemoved);

            control.KeyDown  -= new KeyEventHandler(control_KeyDown);
            control.KeyUp    -= new KeyEventHandler(control_KeyUp);
            control.KeyPress -= new KeyPressEventHandler(control_KeyPress);

            foreach (Control childControl in control.Controls)
            {
                UnRegisterControl(childControl);
            }
        }
コード例 #16
0
 void _invokeWatchTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
 {
     lock (this)
     {
         DateTime now = DateTime.Now;
         for (int i = _invokeResults.Count - 1; i >= 0; i--)
         {
             if (_invokeResults[i].AsyncResult.IsCompleted)
             {
                 _invokeResults.RemoveAt(i);
             }
             else
             if ((now - _invokeResults[i].PublishTime).TotalSeconds > 10)
             {
                 SystemMonitor.Warning("Blocked invoke [" + _invokeResults[i].MethodName + "]");
                 _invokeResults.RemoveAt(i);
             }
         }
     }
 }
コード例 #17
0
        //private void toolStripButtonClear_Click(object sender, EventArgs e)
        //{
        //    listView.VirtualListSize = 0;
        //    listView.Refresh();
        //}

        private void objectListView_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            if (_items.Count <= e.ItemIndex)
            {
                SystemMonitor.Warning("UI inconsitency.");
                return;
            }

            FinancialNewsEvent item = _items[e.ItemIndex];

            e.Item = new ListViewItem("");
            if (item.IsVisible)
            {
                if (item.IsFavourite)
                {
                    e.Item.ImageIndex = 3;
                }
                else
                if (item.IsRead)
                {
                    e.Item.ImageIndex = 0;
                }
                else
                {
                    e.Item.ImageIndex = 1;
                }
            }

            //if (item.Source != null)
            //{// Use index, since image key does not seem to work.
            //    e.Item.ImageIndex = imageList.Images.IndexOfKey(item.Source.Address);
            //}

            e.Item.SubItems.Add(item.Title);
            e.Item.SubItems.Add(GeneralHelper.GetShortDateTimeNoYear(item.DateTime));

            if (_mode == Mode.Marking && IsItemSearched(item))
            {
                e.Item.BackColor = Color.MistyRose;
            }
        }
コード例 #18
0
        void RegisterControl(Control control)
        {
            if (_controls.Contains(control))
            {
                SystemMonitor.Warning("Registered control type already registered not found [ " + control.Name + "]");
                return;
            }

            _controls.Add(control);

            control.ControlAdded   += new ControlEventHandler(control_ControlAdded);
            control.ControlRemoved += new ControlEventHandler(control_ControlRemoved);

            control.KeyDown  += new KeyEventHandler(control_KeyDown);
            control.KeyUp    += new KeyEventHandler(control_KeyUp);
            control.KeyPress += new KeyPressEventHandler(control_KeyPress);

            foreach (Control childControl in control.Controls)
            {
                RegisterControl(childControl);
            }
        }
コード例 #19
0
        public virtual bool StepForward(int steps)
        {
            if (TotalStepsCount < CurrentStep + steps)
            {
                return(false);
            }

            if (StepForwardEvent != null && StepForwardEvent(this, steps) == false)
            {
                return(false);
            }

            foreach (ITimeControl control in SlaveControlsArray)
            {
                if (control.StepForward(steps) == false)
                {
                    SystemMonitor.Warning("Slave control has failed to follow master time control.");
                }
            }

            ChangeCurrentStep(_currentStep + steps);
            return(true);
        }
コード例 #20
0
 /// <summary>
 /// A Warning notifies that in some part of the systems operation a recovarable error has occured.
 /// </summary>
 /// <param name="warningMessage"></param>
 public void Warning(string warningMessage)
 {
     SystemMonitor.Warning(warningMessage);
 }