示例#1
0
        /// <summary>
        /// Converts dictionary into process map and saves it to database
        /// </summary>
        /// <param name="map"></param>
        /// <param name="labels"></param>
        /// <returns></returns>
        private static int SaveMap(Dictionary <string, long> map, List <LogLabel> labels)
        {
            ProcessMapRelation MakeRelation(KeyValuePair <string, long> kv)
            {
                string[] kbs = kv.Key.Split(DICT_SPLITTER);
                return(new ProcessMapRelation()
                {
                    count = kv.Value,
                    labelFrom = kbs[0],
                    labelTo = kbs[1]
                });
            }

            var relations  = map.OrderByDescending(t => t.Value).Select(MakeRelation).ToArray();
            var processMap = new ProcessMap()
            {
                _id       = Job.MapId.ToString(),
                Labels    = labels.Concat(new LogLabel[] { LogLabel.MakeStart(), LogLabel.MakeEnd() }).ToArray(),
                Name      = Job.MapName,
                Relations = relations
            };

            Database.AddMap(processMap);
            return(0);
        }
示例#2
0
        public static (DialogResult res, LabelEditorForm form) GoEdit(LogLabel lb)
        {
            LabelEditorForm form = new LabelEditorForm(lb);
            var             res  = form.ShowDialog();

            return(res, form);
        }
示例#3
0
 private void Log(string message)
 {
     Application.Current.Dispatcher.Invoke(() =>
     {
         LogLabel.Text += $"{DateTime.Now}: {message}{Environment.NewLine}";
         LogLabel.ScrollToEnd();
     });
 }
示例#4
0
 public LabelEditorForm(LogLabel r) : this(r.ProfileName)
 {
     tbName.Text     = r.Name;
     tbJs.Text       = r.JSFilter;
     tbText.Text     = r.Text;
     tbColorHex.Text = r.Color;
     id = r._id;
 }
示例#5
0
        public void UpdateLabel(LogLabel label)
        {
            var col = db.GetCollection <LogLabel>(LABELS_COL_NAME);
            var res = col.ReplaceOne(t => t._id == label._id, label);

            ClearLabelCache(label._id);
            //TODO: check if really replaced
        }
示例#6
0
 public RuleEditorForm(LogLabel r) : this()
 {
     tbName.Text     = r.Name;
     tbJs.Text       = r.JSFilter;
     tbText.Text     = r.Text;
     tbColorHex.Text = r.Color;
     id = r._id;
 }
示例#7
0
        private bool ProfileFilter(LogLabel lb)
        {
            if (_selectedProfile == PROFILES_ALL_NAME)
            {
                return(true);
            }

            return(lb.ProfileName == _selectedProfile);
        }
示例#8
0
        public static async Task DeleteLabel(LogLabel label, string logName)
        {
            int code = await MakeRequest($"/logs/{logName}/labels/{label._id}", "DELETE");

            if (code != 200)
            {
                MessageBox.Show("Api error");
            }
        }
示例#9
0
        public static async Task AddLabel(LogLabel label, string logName)
        {
            var json = JsonConvert.SerializeObject(label);
            int code = await MakeRequest($"/logs/{logName}/labels", "POST", json);

            if (code != 200)
            {
                MessageBox.Show("Api error");
            }
        }
示例#10
0
        private void AppendLog(string LogMessage)
        {
            Debug.Print(string.Format("{0} : {1}", DateTime.Now.ToString(), LogMessage));

            this.Invoke(new Action(delegate {
                //LogLabel.Text += string.Format("{0} : {1}\n", DateTime.Now.ToString(), LogMessage);
                LogLabel.Text = string.Format("{0} : {1}\n", DateTime.Now.ToString(), LogMessage) + LogLabel.Text;
                LogLabel.Invalidate();
            }));
        }
示例#11
0
        private void btOk_Click(object sender, EventArgs e)
        {
            //TODO: validate something?
            Result = new LogLabel()
            {
                _id      = id,
                Name     = tbName.Text,
                JSFilter = tbJs.Text,
                Text     = tbText.Text,
                Color    = ColorTranslator.ToHtml(pbColorExample.BackColor)
            };

            this.DialogResult = DialogResult.OK;
        }
示例#12
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            BankBidLabel.ResetText();

            WinLabel.ResetText();
            LogLabel.ResetText();
            CaseList.Items.Clear();
            ValueLabel.ResetText();

            LogLabel.Text = "Välj bort väskor";

            cases = ge.CreateCases();


            foreach (Case c in cases)
            {
                if (c.Status == true)
                {
                    CaseList.Items.Add(c);
                }
            }
            cases3              = new Stack <Case>(new Stack <Case>(cases));
            cases2              = ge.ShuffleCases(cases3);
            button1.Enabled     = true;
            button2.Enabled     = true;
            button3.Enabled     = true;
            button4.Enabled     = true;
            button5.Enabled     = true;
            button6.Enabled     = true;
            button7.Enabled     = true;
            button8.Enabled     = true;
            button9.Enabled     = true;
            button10.Enabled    = true;
            button11.Enabled    = true;
            button12.Enabled    = true;
            button13.Enabled    = true;
            button14.Enabled    = true;
            button15.Enabled    = true;
            button16.Enabled    = true;
            button17.Enabled    = true;
            button18.Enabled    = true;
            button19.Enabled    = true;
            button20.Enabled    = true;
            button21.Enabled    = true;
            button22.Enabled    = true;
            button23.Enabled    = true;
            button24.Enabled    = true;
            StartButton.Enabled = false;
        }
示例#13
0
        // Adds a log message to the message queue
        private void AddMessage(LogLabel Label, object Input, params object[] Params)
        {
            // Lock the message queue to prevent race conditions
            lock (MessageQueue)
            {
                // Add to message queue
                MessageQueue.Enqueue(new LogMessage
                {
                    Prefix    = ShowPrefix,
                    Label     = Label,
                    Timestamp = DateTime.Now,
                    Message   = string.Format($"{Input}", Params)
                });

                // Signal ready event
                ReadyEvent.Set();
            }
        }
示例#14
0
        public HUD()
        {
            LogList = new List <Pair <string, ColourValue> >(8);
            for (int i = 0; i < 8; i++)
            {
                LogList.Add(new Pair <string, ColourValue>("", ColourValue.Black));
            }

            CompassBg    = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.1f, 0.1f, 0.2f, 0.1f, new ColourValue(1, 1, 1), 1);
            CompassLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.05f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2);
            CompassLabel.SetPosition(0.11f, 0.13f);

            Crosshair = Engine.Singleton.Labeler.NewSimpleQuad("CrosshairMat", Engine.Singleton.GetFloatFromPxWidth(((int)Engine.Singleton.Root.AutoCreatedWindow.Width / 2) - 10), Engine.Singleton.GetFloatFromPxHeight(((int)Engine.Singleton.Root.AutoCreatedWindow.Height / 2) - 10), Engine.Singleton.GetFloatFromPxWidth(20), Engine.Singleton.GetFloatFromPxHeight(20), new ColourValue(1, 1, 1), 2);


            HPHero  = Engine.Singleton.Labeler.NewSimpleQuad("CzerwonyMaterial", 0.05f, 0.05f, 0.1f, 0.05f, new ColourValue(1, 1, 1), 1);
            HPEnemy = Engine.Singleton.Labeler.NewSimpleQuad("ZoltyMaterial", 0.45f, 0.05f, 0.1f, 0.05f, new ColourValue(1, 1, 1), 1);
            Log     = Engine.Singleton.Labeler.NewSimpleQuad("QuadMaterial", 0.8f, 0.8f, 0.18f, 0.18f, new ColourValue(1, 1, 1), 1);

            HPHeroLabel  = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.05f, new ColourValue(1, 0, 0), new ColourValue(1, 0, 0), 2);
            HPEnemyLabel = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.05f, new ColourValue(1, 0, 0), new ColourValue(1, 0, 0), 2);
            LogLabel     = Engine.Singleton.Labeler.NewTextLabel("Primitive", 0.05f, new ColourValue(0.7f, 0.4f, 0), new ColourValue(1, 1.0f, 0.6f), 2);


            LoadScreen = Engine.Singleton.Labeler.NewSimpleQuad("Loading1", 0, 0, 1.0f, 1.0f, ColourValue.White, 4);

            HPHeroLabel.SetPosition(0.055f, 0.055f);
            HPEnemyLabel.SetPosition(0.455f, 0.055f);
            LogLabel.SetPosition(0.82f, 0.82f);

            LogSlots = new LogSlot[8];
            for (int i = 0; i < 8; i++)
            {
                LogSlots[i] = new LogSlot(0.81f, 0.81f + i * 0.02f);
            }

            IsVisible            = false;
            DrawEnemyHP          = false;
            DrawLog              = false;
            LoadScreen.IsVisible = false;
        }
示例#15
0
        public void AddLabel(LogLabel label)
        {
            var col = db.GetCollection <LogLabel>(LABELS_COL_NAME);

            col.InsertOne(label);
        }
        public async Task UpdateLabel(LogLabel label)
        {
            await ApiBoundary.UpdateLabel(label, _state.Info.Name);

            await LoadLabels();
        }
示例#17
0
 public static bool IsStartOrEnd(this LogLabel label)
 {
     return(label._id == LogLabel.START_ID || label._id == LogLabel.END_ID);
 }