示例#1
0
        public xDataOutput getUserDataAsStreamNew()
        {
            xDataOutput o = new xDataOutput(8 * 1024);

            o.writeInt(USER_DATA_SIGNATURE);

            int blockCnt = DATA_BLOCK_COUNT;   //  shares + filters + drawing

            if (_unknownBlocks != null)
            {
                blockCnt += _unknownBlocks.size();
            }
            o.writeInt(blockCnt);

            xDataOutput blockData     = shareGroupsBlock();
            xDataOutput blockGainloss = gainlossBlock();
            xDataOutput blockFilters  = filtersBlock();
            xDataOutput blockDrawings = drawingBlock();

            UserDataBlock.saveBlock(DATA_SHARE_GROUPS, blockData, o);
            UserDataBlock.saveBlock(DATA_GAINLOSS, blockGainloss, o);
            UserDataBlock.saveBlock(DATA_FILTERS_WINDOWS_NEW, blockFilters, o);
            UserDataBlock.saveBlock(DATA_DRAWING, blockDrawings, o);

            if (_unknownBlocks != null)
            {
                for (int i = 0; i < _unknownBlocks.size(); i++)
                {
                    UserDataBlock block = (UserDataBlock)_unknownBlocks.elementAt(i);
                    UserDataBlock.saveBlock(block.id, block.dataInput, o);
                }
            }

            return(o);
        }
示例#2
0
        //==========================================

        xDataOutput filtersBlock()
        {
            xDataOutput o = new xDataOutput(1024);

            FilterManager.getInstance().saveFilterSets(o);

            return(o);
        }
示例#3
0
        static public void saveData()
        {
            String      str = data.toJson();
            xDataOutput o   = new xDataOutput(10 * 1024);

            o.writeUTF(str);
            xFileManager.saveFile(o, "global.dat");
        }
示例#4
0
        public static void saveAppConfig()
        {
            if (appConfig != null)
            {
                String      s = JsonConvert.SerializeObject(appConfig);
                xDataOutput o = new xDataOutput(s.Length * 2);
                o.writeUTF(s);

                xFileManager.saveFile(o, "appconfig2");
            }
        }
示例#5
0
        public void save(xDataOutput o)
        {
            o.writeUTF(this.getName());
            o.writeInt(this.getType());

            int members = this.getTotal();

            o.writeInt(members);
            for (int j = 0; j < members; j++)
            {
                o.writeUTF(this.getCodeAt(j));
            }
        }
示例#6
0
        static public void saveBlock(int id, xDataInput data, xDataOutput o)
        {
            if (data == null)
            {
                return;
            }
            int blockSize = 4 + data.size();

            if (blockSize + o.size() < DATA_MAX)
            {
                o.writeInt(blockSize);
                o.writeInt(id);
                o.write(data.getBytes(), 0, data.size());
            }
        }
示例#7
0
        public void forceFlushUserData()
        {
            if (_flushRequestCount == 0)
            {
                return;
            }

            app.net.NetProtocol net = Context.getInstance().createNetProtocol();
            xDataOutput         o   = getUserDataAsStreamNew();

            net.requestSaveUserData2(o);
            net.flushRequest();

            _flushRequestCount = 0;
            _timeFlushUserData = Utils.currentTimeMillis();
        }
示例#8
0
        //=================================
        xDataOutput gainlossBlock()
        {
            xDataOutput o = new xDataOutput(2 * 1024);

            o.writeInt(_gainLossManager.getTotal());
            for (int i = 0; i < _gainLossManager.getTotal(); i++)
            {
                stGainloss g = _gainLossManager.getGainLossAt(i);

                o.writeUTF(g.code);
                o.writeInt(g.date);
                o.writeInt((int)(g.price * 1000));
                o.writeInt(g.volume);
            }

            return(o);
        }
示例#9
0
        void saveFibonaccie()
        {
            if (!mShouldSaveFile)
            {
                return;
            }
            Share share = mShare;

            if (share == null)
            {
                return;
            }

            string filename = getFilename();

            if (mTrends.size() == 0)
            {
                xFileManager.removeFile(filename);
                return;
            }
            xDataOutput o = new xDataOutput(1000);

            o.writeInt(Context.FILE_VERSION);
            o.writeInt(mTrends.size());
            for (int i = 0; i < mTrends.size(); i++)
            {
                stTrendLine t = (stTrendLine)mTrends.elementAt(i);
                o.writeByte(t.type);
                o.writeInt(t.color);
                o.writeFloat(t.thickness);
                for (int j = 0; j < 3; j++)
                {
                    o.writeFloat(t.candleIdx[j]);
                    //Utils.trace("=====savefile: candle=" + t.candleIdx[j]);
                    o.writeFloat(t.price[j]);
                }

                if (t.type == DRAW_ABC)
                {
                    o.writeUTF((string)t.data);
                }
            }

            //Utils.trace("=====savefile");
            xFileManager.saveFile(o, filename);
        }
示例#10
0
        public void save()
        {
            xDataOutput o = new xDataOutput(2048);

            o.writeInt(FILE_GAINLOSS_VERSION);

            o.writeInt(mGainlosses.size());
            for (int i = 0; i < mGainlosses.size(); i++)
            {
                stGainloss g = (stGainloss)mGainlosses.elementAt(i);
                o.writeUTF(g.code);
                o.writeInt(g.date);
                o.writeFloat(g.price);
                o.writeInt(g.volume);
            }

            xFileManager.saveFile(o, FILE_GAINLOSS);
        }
示例#11
0
        public void save(xDataOutput o)
        {
            o.writeInt(mDate);
            o.writeInt(mShareID);
            o.writeUTF(mCode);
            o.writeByte(mFloorID);
            o.writeFloat(mPriceRef);
            o.writeBoolean(mIsIndex);
            o.writeInt(mMaxTradeVolume);

            o.writeInt(mTradeTransactionCount);
            int cnt = mTradeTransactionCount * FIELD_CNT;

            for (int i = 0; i < cnt; i++)
            {
                o.writeInt(mTradeTransactionBuffer[i]);
            }
        }
示例#12
0
        public void savePriceboard()
        {
            xDataOutput o = new xDataOutput(10000);

            o.writeInt(Context.FILE_VERSION);
            //  indices
            o.writeInt(mIndices.size());
            int i = 0;

            for (i = 0; i < mIndices.size(); i++)
            {
                stPriceboardStateIndex idx = (stPriceboardStateIndex)mIndices.elementAt(i);
                o.writeShort(idx.id);
                o.writeUTF(idx.code);
                o.writeInt(idx.marketID);
                o.writeFloat(idx.current_point);        //	*100
                o.writeFloat(idx.changed_point);        //	*100
                o.writeInt(idx.changed_percent);        //	*100
                o.writeInt((int)idx.total_volume);
                o.writeInt(idx.inc_cnt);
                o.writeInt(idx.ce_cnt);
                o.writeInt(idx.dec_cnt);
                o.writeInt(idx.floor_cnt);
                o.writeInt(idx.ref_num);
                o.writeInt(idx.totalGTGD);              //	*10000
                o.writeInt(idx.market_status);
                o.writeFloat(idx.reference);

                o.writeUTF(idx.mDate);
            }
            //  shares
            for (i = 0; i < mIndices.size(); i++)
            {
                stPriceboardStateIndex idx = (stPriceboardStateIndex)mIndices.elementAt(i);
                stPriceboardState.flush(o, idx.marketID);
            }

            xFileManager.saveFile(o, PRICEBOARD_FILE);
        }
示例#13
0
        public void saveAlarms()
        {
            xDataOutput o = new xDataOutput(2048);

            o.writeInt(Context.FILE_VERSION_LATEST);

            int cnt = mAlarms.size();

            o.writeInt(cnt);
            for (int i = 0; i < cnt; i++)
            {
                stAlarm a = (stAlarm)mAlarms.elementAt(i);
                o.writeUTF(a.code);
                o.writeInt(a.date);
                o.writeInt(a.lowerPrice);
                o.writeInt(a.upperPrice);

                o.writeUTF(a.comment);
            }

            xFileManager.saveFile(o, Context.FILE_ALARM);
        }
示例#14
0
        xDataOutput shareGroupsBlock()
        {
            xDataOutput o = new xDataOutput(5 * 1024);

            xVector v = new xVector();

            for (int i = 0; i < _shareGroups.size(); i++)
            {
                stShareGroup p = (stShareGroup)_shareGroups.elementAt(i);

                if (p.getType() == stShareGroup.ID_GROUP_GAINLOSS || p.getName() == null || p.getName().Length == 0)
                {
                    continue;
                }

                v.addElement(p);
            }
            //

            int groupCnt = v.size() < 30? v.size():30;

            o.writeInt(groupCnt);

            for (int i = 0; i < groupCnt; i++)
            {
                stShareGroup p = (stShareGroup)v.elementAt(i);

                if (p.getType() == stShareGroup.ID_GROUP_GAINLOSS || p.getName() == null || p.getName().Length == 0)
                {
                    continue;
                }

                p.save(o);
            }
            return(o);
        }
示例#15
0
 //=====================================================
 public static void flush(xDataOutput o, int floor)
 {
 }
示例#16
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            int  w        = Screen.PrimaryScreen.WorkingArea.Width;
            int  h        = Screen.PrimaryScreen.WorkingArea.Height;
            bool miniMode = false;

            if (args.Length > 0)
            {
                miniMode = true;
                return;
            }

            string path = System.IO.Directory.GetCurrentDirectory();// Application.ExecutablePath;

            //System.IO.Directory.SetCurrentDirectory(Application.UserAppDataPath);
            if (!runWithoutInstall)
            {
                path = Application.UserAppDataPath;
            }
            //path

            xFileManager.RootDir = Application.StartupPath;
            xFileManager.UserDir = path + "\\vnChart\\";// Application.StartupPath;
            //xFileManager.UserDir = "C:" + "\\vnChart\\";// Application.StartupPath;
            try
            {
                System.IO.Directory.CreateDirectory(xFileManager.UserDir);
                System.IO.Directory.CreateDirectory(xFileManager.UserDir + "\\data");
                //System.IO.Directory.CreateDirectory("vnChart\\data");
            }
            catch (Exception e)
            {
            }

            //MessageBox.Show("C:\\");

            if (xFileManager.RootDir[xFileManager.RootDir.Length - 1] != '\\')
            {
                xFileManager.RootDir = xFileManager.RootDir + "\\";
            }
            //MessageBox.Show("1");
            MainApplication.mMiniMode = miniMode;
            ////    read windows state
            //MessageBox.Show("11");
            xDataInput di = xFileManager.readFile("windstate", false);
            //MessageBox.Show("12");
            int x = 0;
            int y = 0;

            w = w / 2;
            h = h / 2;
            FormWindowState state = FormWindowState.Maximized;

            //MessageBox.Show("2");
            if (w < 600)
            {
                w = 600;
            }
            if (h < 400)
            {
                h = 400;
            }

            if (di != null)
            {
                state = (FormWindowState)di.readInt();
                x     = di.readInt();
                y     = di.readInt();
                w     = di.readInt();
                h     = di.readInt();
            }
            //MessageBox.Show("3");

            MainApplication app = new MainApplication(w, h);

            app.SetBounds(x, y, w, h, BoundsSpecified.All);
            //app.DesktopLocation = new System.Drawing.Point(x, y);
            app.DesktopLocation = new System.Drawing.Point(x, y);

            app.WindowState   = state;
            app.StartPosition = FormStartPosition.Manual;
            //MessageBox.Show("4");
            Application.Run(app);
            //MessageBox.Show("1000");
            if (app.mShouldSaveWindowState)
            {
                xDataOutput o = new xDataOutput(100);
                if (app.WindowState == FormWindowState.Normal)
                {
                    o.writeInt((int)app.WindowState);
                    o.writeInt(app.DesktopLocation.X);
                    o.writeInt(app.DesktopLocation.Y);
                    o.writeInt(app.Size.Width);
                    o.writeInt(app.Size.Height);
                }
                else
                {
                    o.writeInt((int)app.WindowState);
                    o.writeInt(x);
                    o.writeInt(y);
                    o.writeInt(w);
                    o.writeInt(h);
                }
                xFileManager.saveFile(o, "windstate");
            }
        }
示例#17
0
        public xDataOutput getUserDataAsStreamOldVersion()
        {
            xDataOutput o = new xDataOutput(5 * 1024);

            o.writeInt(FILE_ONLINE_USERDATA_VER);
            int i;

            xVector         v                = new xVector(10);
            xVector         mFavorGroups     = shareGroups();
            GainLossManager mGainLossManager = gainLossManager();

            int groupCnt = mFavorGroups.size() < 30?mFavorGroups.size():30;

            for (i = 0; i < groupCnt; i++)
            {
                stShareGroup p = (stShareGroup)mFavorGroups.elementAt(i);

                bool added = false;
                for (int j = 0; j < v.size(); j++)
                {
                    stShareGroup o1 = (stShareGroup)v.elementAt(j);
                    if (o1.getName().CompareTo(p.getName()) == 0)
                    {
                        added = true;
                        break;
                    }
                }

                if (added == false)
                {
                    v.addElement(p);
                }
            }

            o.writeInt(v.size());

            for (i = 0; i < v.size(); i++)
            {
                stShareGroup p = (stShareGroup)v.elementAt(i);

                p.save(o);
            }

            //  gainloss com.data
            o.writeInt(FILE_GAINLOSS_SIGNAL);
            o.writeInt(mGainLossManager.getTotal());
            for (i = 0; i < mGainLossManager.getTotal(); i++)
            {
                stGainloss g = mGainLossManager.getGainLossAt(i);

                o.writeUTF(g.code);
                o.writeInt(g.date);
                o.writeInt((int)g.price);
                o.writeInt(g.volume);
            }

            //  filter sets
            o.writeInt(FILE_FILTER_SET_VERSION);
            FilterManager.getInstance().saveFilterSets(o);

            //  down signal group
            //o.writeInt(FILE_DOWN_SIGNAL);
            //mAlarmGroup.save(o);

            return(o);
        }