예제 #1
0
        private static void LoadOneClassProperties <TypeViewModel>(object classWithProps, TypeViewModel marketViewmodel)
        {
            classWithProps.GetType().GetProperties().ToList().ForEach(
                propertyConfig =>
            {
                try
                {
                    var valueConfig = propertyConfig.GetValue(classWithProps, null);
                    if (valueConfig != null)
                    {
                        marketViewmodel.GetType().GetProperties().ToList().ForEach(
                            propertyViewMdl =>
                        {
                            if (propertyViewMdl.Name == propertyConfig.Name)
                            {
                                //string stVal = val.ToString();
                                //propertyConfig.SetValue(classWithProps, stVal, null);
                                //propertyViewMdl.SetValue(marketViewmodel, valueConfig, null);
                                CUtilReflex.SetPropertyValue(marketViewmodel, propertyViewMdl, valueConfig);
                            }
                        }

                            );
                    }
                }
                catch (Exception e)
                {
                    CKernelTerminal.ErrorStatic("LoadOneClassProperties", e);
                }
            }
                );
        }
 private void OpenChildWindow <TChildWindow>() where TChildWindow : Window
 {
     GUIDispMainWindow.Invoke(new Action(() =>
     {
         CKernelTerminal.OpenChildWindow <TChildWindow>();
     }));
 }
예제 #3
0
        private void TaskSaver()
        {
            try
            {
                _evDataLoaded.WaitOne();


                while (true)
                {
                    _evSave.WaitOne();

                    List <CLevelEl> lst = GetCopy();
                    if (lst != null)
                    {
                        _levelsIO.WriteToFile(lst);
                    }



                    // Thread.Sleep(1000);
                }
            }
            catch (Exception e)
            {
                CKernelTerminal.ErrorStatic("CUserLevels.TaskSaver", e);
            }
        }
        private void IncDecTextBox(IncDec incdecPat, TextBlock txtBlock)
        {
            uint num;

            try
            {
                string txt = txtBlock.Text;

                num = Convert.ToUInt32(txt);
            }
            catch (Exception exc)
            {
                CKernelTerminal.ErrorStatic("IncDecTextBox", exc);

                return;
            }

            //TODO chek min max values
            if (incdecPat == IncDec.DoInc)
            {
                num++;
            }
            else if (incdecPat == IncDec.DoDec)
            {
                num--;
            }

            num           = Math.Max(num, 1);
            txtBlock.Text = Convert.ToString(num);
        }
        public ControlMarket(int stockNum, MainWindow mainWindow)
        {
            InitializeComponent();
            //StockNum = stockNum;

            _mainWindow = mainWindow;

            _kernelTerminal = CKernelTerminal.GetKernelTerminalInstance();



            StockNum = stockNum;
            Loaded  += new RoutedEventHandler(ControlMarket_Loaded);
            ControlStockInstance.PriceCoordChanged += new EventHandler(OnPriceCoordChanged);
            ControlStockInstance.PriceCoordChanged += new EventHandler(ControlDealsInstance.OnPriceCoordChanged);
            ControlStockInstance.PriceCoordChanged += new EventHandler(ControlClustersInstance.OnPriceCoordChanged);


            //note: subscribe ControlMarket to MouseWheel event of ControlStock
            ControlStockInstance.DoScrollAllControls += new EventHandler(OnControllStockScrolled);

            /*  if (_modeMouse)
             * {
             *    MouseActiveIcon.Visibility = Visibility.Visible;
             * }
             * else if (!_modeMouse)
             * {
             *    MouseActiveIcon.Visibility = Visibility.Collapsed;
             * }
             */
            ControlStockInstance.PositionGrid = PositionGrid;



            ControlDealsInstance.LstLevel2     = ControlStockInstance.TenLevels;
            ControlDealsInstance.LstLevel1     = ControlStockInstance.FiftyLevels;
            ControlDealsInstance.DictPriceY    = ControlStockInstance.DictPriceY;
            ControlClustersInstance.DictPriceY = ControlStockInstance.DictPriceY;

            ControlClustersInstance.GetAvailableSpaceForScrollViewer = GetFreeSpaceForControlCluster;


            _timerCheckCoord.Elapsed += new ElapsedEventHandler(TimerCheckCoord_Elapsed);
            _timerCheckCoord.Start();



            //KAA onfocus event
            DoAllFocused += ToFocus;


            PreviewKeyDown += new KeyEventHandler(ControlMarket_PreviewKeyDown);
            PreviewKeyUp   += new KeyEventHandler(ControlMarket_PreviewKeyUp);
            //_mainWindow = (MainWindow)CUtilWin.FindWindow<MainWindow>();
            _mainWinDispatcher = Dispatcher.CurrentDispatcher;

            GenDPList();

            MouseDown += new MouseButtonEventHandler(ControlMarket_MouseDown);
        }
예제 #6
0
        public void Error(string msg, Exception e)
        {
            // if (_alarmer !=null)
            // _alarmer.Error(msg, e);

            CKernelTerminal.ErrorStatic(msg, e);
        }
예제 #7
0
        private static void UpdateOneClassProperties <TypeViewModel>(object classWithProps, TypeViewModel marketViewmodel)
        {
            classWithProps.GetType().GetProperties().ToList().ForEach(
                propertyConfig =>
            {
                try
                {
                    var value = propertyConfig.GetValue(classWithProps, null);
                    if (value != null)
                    {
                        marketViewmodel.GetType().GetProperties().ToList().ForEach(
                            propertyViewMdl =>
                        {
                            if (propertyViewMdl.Name == propertyConfig.Name)
                            {
                                object val   = propertyViewMdl.GetValue(marketViewmodel, null);
                                string stVal = val.ToString();
                                propertyConfig.SetValue(classWithProps, stVal, null);
                            }
                        }

                            );
                    }
                }
                catch (Exception e)
                {
                    CKernelTerminal.ErrorStatic("UpdateOneClassProperties", e);
                }
            }



                );
        }
예제 #8
0
        public T LoadData()
        {
            CleanOldData();

            T list = new T();


            string path = GetFileName();


            FileStream serializationStream = null;

            try
            {
                if (File.Exists(path) && CUtil.FileSize(path) != 0)
                {
                    serializationStream = new FileStream(path, FileMode.Open);
                }
                else
                {
                    //File.Create(path);
                    return(list);
                }
            }
            catch (IOException e)
            {
                CKernelTerminal.ErrorStatic("IO Error in LoadData " + _subdir, e);
            }
            catch (Exception e)
            {
                CKernelTerminal.ErrorStatic("Error in LoadData " + _subdir, e);
            }
            if (serializationStream == null)
            {
                return(new T());
            }
            try
            {
                BinaryFormatter formatter = new BinaryFormatter();
                list = (T)formatter.Deserialize(serializationStream);
            }
            catch (SerializationException e)
            {
                CKernelTerminal.ErrorStatic("Serialization error in LoadData " + _subdir, e);
            }
            catch (Exception e)
            {
                CKernelTerminal.ErrorStatic("Common error during serialization in LoadData " + _subdir, e);
            }
            finally
            {
                serializationStream.Close();
            }

            return(list);
        }
예제 #9
0
        //private CKernelTerminal _kernelTerminal;



        public CEvntDispTerminal(CKernelTerminal kernelTerminal)
        {
            // CreateCommandBinding(EventsGUI.ConnectToServer, kernelTerminal.Communicator.OnUserTryConnectToServer,
            //                                               DefaultCanDo);

            CreateCommandBinding(EventsGUI.ConnectToServer, kernelTerminal.OnUserTryConnectToServer, DefaultCanDo);
            CreateCommandBinding(EventsGUI.ErrorMessage, kernelTerminal.OnErrorMessageFromGUI, DefaultCanDo);
            CreateCommandBinding(EventsGUI.CloseInstrumentPositions, kernelTerminal.CloseInstrumentPostions, DefaultCanDo);
            CreateCommandBinding(EventsGUI.CancellInstrumentOrders, kernelTerminal.CancellInstrumentOrders, DefaultCanDo);
            CreateCommandBinding(EventsGUI.CloseAllPositions, kernelTerminal.CloseAllPositions, DefaultCanDo);
            CreateCommandBinding(EventsGUI.CancellAllOrders, kernelTerminal.CancellAllOrders, DefaultCanDo);
        }
        public ControlClusters()
        {
            InitializeComponent();

            IsInitializeComplete = false;


            GenDPList();

            _renderer = new CRenderer(this, _drwVis);
            _alarmer  = CKernelTerminal.GetKernelTerminalInstance().Alarmer;

            if (_typeFaceDefault == null)
            {
                _typeFaceDefault = new Typeface(_fontFamilyDefault, FontStyles.Normal, _fontWeightDefault, new FontStretch());
            }
            _penClusterTotal = new Pen(Brushes.LightGray, 1.0);
            //KAA removed 2016-May-31
            // StringHeight = 13;
            _lstImageSegments.Add(Image_0);
            _lstImageSegments.Add(Image_1);
            _lstImageSegments.Add(Image_2);
            _lstImageSegments.Add(Image_3);
            _lstImageSegments.Add(Image_4);
            _lstImageSegments.Add(Image_5);
            _lstImageSegments.Add(Image_6);
            _lstImageSegments.Add(Image_7);
            _lstImageSegments.Add(Image_8);
            _lstImageSegments.Add(Image_9);

            ScrollViewerClusters.ScrollToRightEnd();

            for (int i = 0; i < _lstImageSegments.Count; i++)
            {
                RenderOptions.SetBitmapScalingMode(_lstImageSegments[i], BitmapScalingMode.NearestNeighbor);
                TextOptions.SetTextRenderingMode(_lstImageSegments[i], TextRenderingMode.ClearType);
                TextOptions.SetTextFormattingMode(_lstImageSegments[i], TextFormattingMode.Display);
            }
            RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);



            //  CUtil.TaskStart(TaskTriggerPaint);
            CUtil.ThreadStart(ThreadDrawClusters);


            SizeChanged += ControlClusters_SizeChanged;

            GridCanvasControlClusters.MouseEnter += GridCanvasControlClusters_MouseEnter;

            _guiDispatcher = Dispatcher.CurrentDispatcher;
        }
예제 #11
0
        /// <summary>
        /// Set instrument parameters for  Empty
        /// viewmodel. Calling when set real
        /// instrument selected.
        ///
        /// If instrument was trade previously
        /// settings file must be exists, load data from it.
        ///
        ///  If instrument was not trade previously
        ///  settings file is not exist use ticker data receieved
        ///  from the server
        ///
        /// Calling from CKernelTerminal.EditNonConnectedStock
        /// </summary>
        /// <param name="conId"></param>
        /// <param name="ticker">ticker data(instrument, step, decimals, etc)
        ///                      recieved from the server
        /// </param>
        public void SetEmptyVewModelInstrParams(int conId, CTIckerData ticker)
        {
            if (_logger == null)
            {
                _logger = new CLogger("MarketViewModel_" + ticker.TickerName);
            }



            string pathToConfig = CKernelTerminal.GetInstruemntPath(ticker.TickerName);

            //Config file for instrument is exists
            if (File.Exists(pathToConfig))
            {
                _instrumentConfig = _kernelTerminal.LoadInstrumentConfig(ticker.TickerName);
                CDataBinder.LoadMarketConfig(_instrumentConfig, this);

                //added 2018-02-27 for bitfinix capability
                if (_bUpdInstrParamsFromGrid)
                {
                    Step          = (double)ticker.Step;
                    DecimalVolume = ticker.DecimalVolume;
                    Decimals      = ticker.Decimals;
                }
            }
            //Config file for instrument is not exists
            else
            {
                TickerName    = ticker.TickerName;
                Step          = (double)ticker.Step;
                DecimalVolume = ticker.DecimalVolume;
                Decimals      = ticker.Decimals;


                _instrumentConfig.Name = ticker.TickerName;
                _instrumentConfig.MarketProperties.StockProperties.TickerName = ticker.TickerName;
                _instrumentConfig.MarketProperties.StockProperties.Step       = ticker.Step.ToString();
                _instrumentConfig.MarketProperties.StockProperties.Decimals   = ticker.Decimals.ToString();


                _instrumentConfig.MarketProperties.DealsProperties.Step = ticker.Step.ToString();
                _instrumentConfig.FileName = CKernelTerminal.GetInstruemntPath(ticker.TickerName);



                (new Task(SaveInstrumentConfig)).Start();
            }


            //note: ConId use for both cases
            ConnId = conId;
        }
        private void ButtonConnection_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            //Window winConn =   CKernelTerminal.OpenChildWindow<ConnectionsWindow>();

            Window winConn = CKernelTerminal.GetViewModelDispatcherInstance().
                             OpenChildWindow <ConnectionsWindow>(showAtStartup: false);

            if (winConn != null)
            {
                _mainWindow.SuspendTopMost(winConn);
                winConn.ShowDialog();
            }
        }
예제 #13
0
 /// <summary>
 /// Call from  MarketViewModel.SetEmptyVewModelInstrParams
 /// </summary>
 /// <param name="instrumentConfig"></param>
 /// <param name="marketViewModel"></param>
 public static void LoadMarketConfig(CInstrumentConfig instrumentConfig, MarketViewModel marketViewModel)
 {
     try
     {
         LoadOneClassProperties(instrumentConfig.MarketProperties.StockProperties, marketViewModel);
         LoadOneClassProperties(instrumentConfig.MarketProperties.DealsProperties, marketViewModel);
         LoadOneClassProperties(instrumentConfig.MarketProperties.ClusterProperties, marketViewModel);
     }
     catch (Exception e)
     {
         CKernelTerminal.ErrorStatic("LoadMarketConfig");
     }
 }
 private void ControlMarket_PreviewMouseDown(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (!base.IsKeyboardFocused)
         {
             DoAllFocused();
         }
     }
     catch (Exception exc)
     {
         CKernelTerminal.ErrorStatic("ControlMarket_PreviewMouseDown", exc);
     }
 }
예제 #15
0
        public List <CServer> _lstServers;// = new List<CServer>();

        public ViewModelConnection(CKernelTerminal kernerlTerminal)
        {
            _kernelTerminal = kernerlTerminal;

            // CServersConf serverConf = kernerlTerminal.Communicator.ServersConf;

            /*  _lstServers =
             *    new List<CServer>
             *        (_kernelTerminal.Communicator.ServersConf.Servers);
             */
            _lstServers = new List <CServer>();
            _kernelTerminal.Communicator.ServersConf.Servers.
            ForEach(a => _lstServers.Add((CServer)a.Copy()));
        }
예제 #16
0
 private void TaskLoadData()
 {
     try
     {
         _lstLevels = _levelsIO.LoadData();
     }
     catch (Exception e)
     {
         CKernelTerminal.ErrorStatic("UserLevels TaskLoadData", e);
     }
     finally
     {
         _evDataLoaded.Set();
     }
 }
예제 #17
0
 private void ColorList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         CColor cclr          = ((CColor)e.AddedItems[0]);
         Color  selectedColor = (Color)ColorConverter.ConvertFromString(cclr.Name);
         Brush  brush         = new SolidColorBrush(selectedColor);
         //Brush selectedColor = (Brush)(e.AddedItems[0] as CColor).GetValue(null, null);
         rtlfill.Fill = brush;
     }
     catch (Exception exc)
     {
         CKernelTerminal.ErrorStatic("ColorSelectionWindow.ColorList_SelectionChanged", exc);
     }
 }
예제 #18
0
 public static void UpdateTerminalConfig(CTerminalProperties terminalProperties, TerminalViewModel termViewModel)
 {
     try
     {
         UpdateOneClassProperties(terminalProperties.TerminalCommonProperties, termViewModel);
         UpdateOneClassProperties(terminalProperties.TerminalStockProperties, termViewModel);
         UpdateOneClassProperties(terminalProperties.TerminalDealsProperties, termViewModel);
         UpdateOneClassProperties(terminalProperties.TerminalClustersProperties, termViewModel);
         UpdateOneClassProperties(terminalProperties.TerminalGlobalProperties, termViewModel);
     }
     catch (Exception e)
     {
         CKernelTerminal.ErrorStatic("UpdateTerminalConfig", e);
     }
 }
예제 #19
0
        public void WriteToFile(T dataToSeirilze)
        {
            string path = GetFileName();

            FileStream fileStream = null;

            try
            {
                //if file exists and valid use it
                if (File.Exists(path) && CUtil.FileSize(path) > 0)
                {
                    fileStream = new FileStream(path, FileMode.Create);
                }
                //if not create new file
                else
                {
                    fileStream = File.Create(path);
                    //serializationStream = new FileStream(path, FileMode.Open);
                }
            }
            catch (IOException e)
            {
                CKernelTerminal.ErrorStatic("WriteToFile IO " + _subdir, e);
            }
            catch (Exception e)
            {
                CKernelTerminal.ErrorStatic("WriteToFile " + _subdir, e);
            }


            if (fileStream != null)
            {
                BinaryFormatter formatter = new BinaryFormatter();
                try
                {
                    formatter.Serialize(fileStream, dataToSeirilze);
                }
                catch (Exception e)
                {
                    CKernelTerminal.ErrorStatic("WriteToFile Serialize", e);
                }
                finally
                {
                    fileStream.Close();
                }
            }
        }
예제 #20
0
 public static void SaveMarketConfig(CInstrumentConfig instrumentConfig, MarketViewModel marketViewModel)
 {
     try
     {
         UpdateOneClassProperties(instrumentConfig.MarketProperties.StockProperties, marketViewModel);
         UpdateOneClassProperties(instrumentConfig.MarketProperties.DealsProperties, marketViewModel);
         //2018-08-21 protect against file corruption on file saving when cluster was not loaded yet
         if (marketViewModel.TimeFrame != null)
         {
             UpdateOneClassProperties(instrumentConfig.MarketProperties.ClusterProperties, marketViewModel);
         }
     }
     catch (Exception e)
     {
         CKernelTerminal.ErrorStatic("UpdateMarketConfig", e);
     }
 }
        public void RouteEvent(object sender, ExecutedRoutedEventArgs e)
        {
            try
            {
                RoutedUICommand cmd = (RoutedUICommand)e.Command;

                if (!_dictCmdEventHandler.ContainsKey(cmd))
                {
                    CKernelTerminal.ErrorStatic("CEventRouterViewModel.RouteEvent command not found");
                    return;
                }
                _dictCmdEventHandler[cmd].Invoke(sender, e);
            }
            catch (Exception excp)
            {
                CKernelTerminal.ErrorStatic("Error in RouteEvent", excp);
            }
        }
예제 #22
0
        private void VM_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //   System.Threading.Thread.Sleep(0);

            DataGrid dg = (DataGrid)sender;

            int ind = dg.SelectedIndex;

            if (ind >= 0)
            {
                var el = (ModelStockRecord)dg.SelectedItem;


                ViewModelDetailedVM vm = (ViewModelDetailedVM)
                                         CKernelTerminal.GetViewModelDispatcherInstance().GetViewModelChilInst <ViewModelDetailedVM>();

                vm.ConIdToShow = el.ConId;
            }
        }
예제 #23
0
        public static void BindAllFromViewModel <TypeOfViewModel>(TypeOfViewModel viewModel, DependencyObject dependencyObject)
        {
            viewModel.GetType().GetProperties().ToList().ForEach(
                property =>
            {
                try
                {
                    string propertyName = property.Name;

                    string dpName = property.Name + "Property";
                    PropertyInfo propertyViewModel = viewModel.GetType().GetProperty(propertyName);


                    Type typeDependObj = dependencyObject.GetType();



                    FieldInfo fieldDP = CUtilReflex.GetDependencyPropertyField(propertyName, typeDependObj);
                    if (fieldDP == null)
                    {
                        throw new ApplicationException("Field " + dpName + " not found in " + typeDependObj.Name);
                    }

                    DependencyProperty dp = (DependencyProperty)fieldDP.GetValue(dependencyObject);

                    /* Bind ViewModel property and DependencyProperty of Control.
                     * If ViewModel property is writable, use two way binding
                     *
                     */
                    CUtil.SetBinding(viewModel,
                                     propertyName,
                                     dependencyObject,
                                     dp,
                                     twoWayBinding: propertyViewModel.CanWrite);
                }
                catch (Exception e)
                {
                    CKernelTerminal.ErrorStatic("BindAllFromViewModel", e);
                }
            }
                );
        }
예제 #24
0
        //==========================================================================================================
        //============================== PUBLIC METHODS ============================================================
        //==========================================================================================================



        /// <summary>
        /// Call from CCommunicator
        /// </summary>
        /// <param name="kernelTerminal"></param>
        /// <param name="childWinDataUpdater"></param>
        /// <param name="authResponse"></param>
        /// <param name="connId"></param>
        public CDataReciever(CKernelTerminal kernelTerminal, IChildWinDataUpdater childWinDataUpdater,
                             AuthResponseEventHandler authResponse, int connId)
        {
            _kernelTerminal      = kernelTerminal;
            _childWinDataUpdater = childWinDataUpdater;
            AuthResponse         = authResponse;

            _connId           = connId;
            OutpListAggrDeals = new Dictionary <string, List <CDealClass> >();// List<CDealClass>();
            OutpListRawDeals  = new Dictionary <string, List <CDealClass> >();


            //2018-04-23
            _logger = new CLogger("DataReciever");

            _terminalViewModel = _kernelTerminal.ViewModelDispatcher.TerminalViewModel;
            _messenger         = new CMessenger();

            _dbg = new DBGDataRcvr(isOn: _kernelTerminal.GlobalConfig.DebugStocks);
        }
        public BaseTerminalWindow()
        {
            // KernelTerminal = ((App)Application.Current).KernelTerminal;
            KernelTerminal = CKernelTerminal.GetKernelTerminalInstance();

            this.SizeChanged     += new SizeChangedEventHandler(BaseTerminalWindow_SizeChanged);
            this.LocationChanged += new EventHandler(BaseTerminalWindow_LocationChanged);
            // this.Loaded += new RoutedEventHandler(BaseTerminalWindow_Loaded);
            this.Initialized += new EventHandler(BaseTerminalWindow_Initialized);
            this.Closed      += new EventHandler(BaseTerminalWindow_Closed);

            _typeOfWindow = this.GetType();
            _geomWindow   = new CGeomWindow
            {
                TypeOfWindow = _typeOfWindow.ToString(),
                IsOpened     = true
            };

            //  (new Task(TaskSaveWindowLocation)).Start();
        }
예제 #26
0
        public void OpenAuthWindow(int connId, string stockName)
        {
            _kernelTerminal = CKernelTerminal.GetKernelTerminalInstance();
            AuthWindow aw = (AuthWindow)_kernelTerminal.ViewModelDispatcher.OpenChildWindow <AuthWindow>(false);

            aw.Left = this.Left + 30;
            aw.Top  = this.Top + 30;

            aw.SetParams(connId, stockName);
            Window win = (Window)aw;

            CUtilWin.ShowActivated(ref win);

            /*
             * AuthWindow aw = (AuthWindow) _kernelTerminal.ViewModelDispatcher.GetViewChild<AuthWindow>();
             * aw.SetParams(connId, stockName);
             * aw.Closed += new EventHandler(aw_Closed);
             * aw.ShowDialog();
             */
        }
예제 #27
0
        public void OpenDetailedVM()
        {
            try
            {
                ViewModelDetailedVM vm = (ViewModelDetailedVM)
                                         CKernelTerminal.GetViewModelDispatcherInstance().GetViewModelChilInst <ViewModelDetailedVM>();

                // int ind = VMControlDatagrid.VM.SelectedIndex;


                CKernelTerminal.OpenChildWindow <DetailedVMWindow>();
                vm.BindGrid();

                /* CKernelTerminal kernTeminal = CKernelTerminal.GetKernelTerminalInstance();
                 *
                 *
                 *
                 *
                 * DetailedVMWindow win =
                 *  (DetailedVMWindow)kernTeminal.ViewModelDispatcher.OpenChildWindow<DetailedVMWindow>();
                 *
                 *
                 * win.Left = this.Left + 10;
                 * win.Top = this.Top + 10;
                 */
                //  win.Left = this.Left - 100;

                //    win.Left = 2800;
                //  win.Top = 400;

                // win.Show();
            }

            catch (Exception e)
            {
                Error("VMWindow.OpenDetailedVM", e);
            }
        }
예제 #28
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                List <CColor> lstColors = CKernelTerminal.GetKernelTerminalInstance().ColorList.ListColors;

                ColorList.ItemsSource = lstColors;

                //PropertyInfo[] props = typeof(Brushes).GetProperties();

                string stFill        = rtlfill.Fill.ToString();
                Color  colorSelected = (Color)ColorConverter.ConvertFromString(stFill);
                string stColor       = colorSelected.ToString();

                for (int i = 0; i < lstColors.Count; i++)
                {
                    string colorName = lstColors[i].Name;
                    Color  clr       = (Color)ColorConverter.ConvertFromString(colorName);

                    if (clr == colorSelected)
                    {
                        ColorList.SelectedItem = ColorList.Items[i];
                        //ColorList.SelectedIndex = i;
                        ColorList.UpdateLayout();
                        var listBoxItem = (ListBoxItem)ColorList.ItemContainerGenerator.ContainerFromItem(ColorList.SelectedItem);



                        listBoxItem.Focus();
                    }
                }
            }
            catch (Exception exc)
            {
                CKernelTerminal.ErrorStatic("ColorSelectionWindow.Window_Loaded", exc);
            }
        }
 private void Window_Closed(object sender, EventArgs e)
 {
     CKernelTerminal.SaveTerminalProperties();
 }
예제 #30
0
        public MarketViewModel(int stockNum, ControlMarket controlMain, CKernelTerminal kernelTerminal,
                               CStocksVisual stockVisual, CInstrumentConfig instrumentConfig)
        {
            StockNum = stockNum;
            string tickerName = stockVisual.Ticker;


            IsAlive = true;
            IsDead  = false;


            SelectionMode = new CSelectionMode();
            string tf = instrumentConfig.MarketProperties.ClusterProperties.TimeFrame;

            _clusterProcessor = new CClusterProcessor(tickerName, tf);
            _userLevels       = new CUserLevels(tickerName);


            _eventRouterViewModel = new CEventRouterViewModel(this);

            // int conId = stockVisual.ConNumm;



            _orders = new OrderData[Params.MaxUserOrdersPerInstr];



            _terminalViewModel = CViewModelDispatcher.GetTerminalViewModel();



            int parUpdateStockPerSec = kernelTerminal.TerminalConfig.UpdateStockPerSec;

            _parSleep = (int)(1 / (double)parUpdateStockPerSec * 1000);

            _instrumentConfig = instrumentConfig;

            //    (new Thread(TestPar)).Start();


            GUIDispatcher = System.Windows.Threading.Dispatcher.CurrentDispatcher;

            _controlMarket  = controlMain;
            _kernelTerminal = kernelTerminal;
            _communicator   = kernelTerminal.Communicator;

            //TextPriceSize = "10";
            //  StringHeight = "10";

            CurrAmountNum  = "0";
            ListWorkAmount = new List <CWorkAmount>();

            SetInstrumentParams(stockVisual);
            _vmUserPos = new ViewModelUserPos(Decimals, Step);



            _parMaxVolumeBar = Int32.MaxValue;

            //RaisePropertyChanged("Contract_ShortName");


            ConnId = stockVisual.ConNumm;// conId;



            MonitorUserOrders = new Dictionary <long, COrder>();


            if (tickerName != null)
            {
                _logger = new CLogger("MarketViewModel_" + tickerName);
            }

            Log("Start logging__________________________________________");



            InitBidsAsks();



            //TODO remove
            this.InitializeStockData();

            SetMouseMode(true);

            _threadDataReciever = new Thread(ThreadDataReciever);
            _threadDataReciever.Start();


            //BindWorkAmount();
        }