示例#1
0
 private void dropList_ItemClicked(System.Object sender, ToolStripItemClickedEventArgs e) //e As System.Windows.Forms.MouseEventArgs)
 {
     for (var i = 0; i <= paramList.Count - 1; i++)
     {
         if (paramList.ElementAt(i).dropList.Equals(sender))
         {
             setValue(System.Convert.ToString(paramList.ElementAt(i).paramName), System.Convert.ToString(paramList.ElementAt(i).optionsValue[paramList.ElementAt(System.Convert.ToInt32(i)).dropList.Items.IndexOf(e.ClickedItem)]));
             if (NewValueEvent != null)
             {
                 NewValueEvent(paramList.ElementAt(i).paramName, paramList.ElementAt(i).optionsValue[paramList.ElementAt(i).dropList.Items.IndexOf(e.ClickedItem)]);
             }
             break;
         }
     }
 }
示例#2
0
 public Connection GetConnectionInfo(int connectionID)
 {
     if (_connectioniInfos.Count == 1)
     {
         return(_connectioniInfos.ElementAt(0));
     }
     else if (_connectioniInfos == null || _connectioniInfos.Count == 0)
     {
         return(null);
     }
     else
     {
         return(_connectioniInfos.FirstOrDefault(p => p.ConnectionID == connectionID));
     }
 }
示例#3
0
        private IEnumerable <BFUDetailsRowColumn <TItem> > GetJustifiedColumns(IEnumerable <BFUDetailsRowColumn <TItem> > newColumns, CheckboxVisibility newCheckboxVisibility, SelectionMode newSelectionMode, double viewportWidth, int resizingColumnIndex)
        {
            var    rowCheckWidth      = newSelectionMode != SelectionMode.None && newCheckboxVisibility != CheckboxVisibility.Hidden ? 48 : 0; //DetailsRowCheckbox width
            var    groupExpandedWidth = 0;                                                                                                     //skipping this for now.
            double totalWidth         = 0;
            var    availableWidth     = viewportWidth - (rowCheckWidth + groupExpandedWidth);
            int    count = 0;

            System.Collections.Generic.List <BFUDetailsRowColumn <TItem> > adjustedColumns = new System.Collections.Generic.List <BFUDetailsRowColumn <TItem> >();
            foreach (var col in newColumns)
            {
                adjustedColumns.Add(col);
                col.CalculatedWidth = !double.IsNaN(col.MinWidth) ? col.MinWidth : 100;
                if (_columnOverrides.TryGetValue(col.Key, out var overridenWidth))
                {
                    col.CalculatedWidth = overridenWidth;
                }

                var isFirst = count + resizingColumnIndex == 0;
                totalWidth += GetPaddedWidth(col, isFirst);
            }

            var lastIndex = adjustedColumns.Count() - 1;

            // Shrink or remove collapsable columns.
            while (lastIndex > 0 && totalWidth > availableWidth)
            {
                var col           = adjustedColumns.ElementAt(lastIndex);
                var minWidth      = !double.IsNaN(col.MinWidth) ? col.MinWidth : 100;
                var overflowWidth = totalWidth - availableWidth;

                if (col.CalculatedWidth - minWidth >= overflowWidth || !col.IsCollapsible)
                {
                    var originalWidth = col.CalculatedWidth;
                    col.CalculatedWidth = Math.Max(col.CalculatedWidth - overflowWidth, minWidth);
                    totalWidth         -= originalWidth - col.CalculatedWidth;
                }
                else
                {
                    totalWidth -= GetPaddedWidth(col, false);
                    adjustedColumns.RemoveRange(lastIndex, 1);
                }
                lastIndex--;
            }

            //Then expand columns starting at the beginning, until we've filled the width.
            for (var i = 0; i < adjustedColumns.Count && totalWidth < availableWidth; i++)
            {
                var col          = adjustedColumns[i];
                var isLast       = i == adjustedColumns.Count - 1;
                var hasOverrides = _columnOverrides.TryGetValue(col.Key, out var overrides);
                if (hasOverrides && !isLast)
                {
                    continue;
                }

                var    spaceLeft = availableWidth - totalWidth;
                double increment = 0;
                if (isLast)
                {
                    increment = spaceLeft;
                }
                else
                {
                    var maxWidth = col.MaxWidth;
                    var minWidth = !double.IsNaN(col.MinWidth) ? col.MinWidth : (!double.IsNaN(col.MaxWidth) ? col.MaxWidth : 100);
                    increment = !double.IsNaN(maxWidth) ? Math.Min(spaceLeft, maxWidth - minWidth) : spaceLeft;
                }

                col.CalculatedWidth += increment;
                totalWidth          += increment;
            }

            return(adjustedColumns);
        }
        public void goToBadge()
        {
            //Creates badge detail image -- need assets
            UIImageView image = new UIImageView(UIImage.FromFile("defaultBadge.png"));

            UIViewController badgeDetailView = new UIViewController();

            badgeDetailView.EdgesForExtendedLayout = UIRectEdge.None;
            badgeDetailView.Add(image);

            //Create badge title bar
            UILabel label               = new UILabel(new System.Drawing.RectangleF(0, 230, (float)UIScreen.MainScreen.Bounds.Width, 60));
            var     documents           = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            var     dbPath              = Path.Combine(documents, "db_sqlite-net.db");
            var     db                  = new SQLiteConnection(dbPath);
            var     table               = db.Table <MagpieBadge>();
            CLLocationCoordinate2D anno = annotationScrollList[currentAnno];
            var query = db.Query <MagpieBadge>("SELECT * FROM MagpieBadge WHERE lon = " + anno.Longitude);

            label.Text = query[0].bname;
            if (label.Text.Length < 30)
            {
                label.Font = UIFont.FromName("Montserrat-Light", 24f);
            }
            else
            {
                label.Font = UIFont.FromName("Montserrat-Light", 18f);
            }
            label.TextColor       = UIColor.White;
            label.BackgroundColor = UIColor.LightGray;
            label.TextAlignment   = UITextAlignment.Center;
            badgeDetailView.Add(label);
            //end badge title bar

            //Holds the view map button and share button
            UIView buttonBar = new UIView(new System.Drawing.RectangleF(0, 290, (float)UIScreen.MainScreen.Bounds.Width, 90));

            buttonBar.BackgroundColor = UIColor.DarkGray;

            //Build map button
            UIButton viewInMapBtn = new UIButton(new System.Drawing.RectangleF(50, 15, 40, 40));

            viewInMapBtn.SetImage(UIImage.FromFile("mapIcon.png"), UIControlState.Normal);

            UILabel mapBtnLabel = new UILabel(new System.Drawing.RectangleF(20, 60, 100, 20));

            mapBtnLabel.Text          = "VIEW IN MAP";
            mapBtnLabel.TextAlignment = UITextAlignment.Center;
            mapBtnLabel.Font          = UIFont.FromName("Montserrat-Bold", 12f);
            mapBtnLabel.TextColor     = UIColor.White;
            buttonBar.Add(mapBtnLabel);

            viewInMapBtn.TouchUpInside += (object sender, EventArgs e) =>
            {
                this.selected = query[0].bid;
                NavigationController.PopViewController(true);
            };


            buttonBar.Add(viewInMapBtn);
            //end map button

            //Build share button
            UIButton shareBtn = new UIButton(new System.Drawing.RectangleF((float)(UIScreen.MainScreen.Bounds.Width - 90), 15, 40, 40));

            shareBtn.SetImage(UIImage.FromFile("shareIcon.png"), UIControlState.Normal);

            UILabel shareBtnLabel = new UILabel(new System.Drawing.RectangleF((float)(UIScreen.MainScreen.Bounds.Width - 100), 60, 60, 20));

            shareBtnLabel.Text          = "SHARE";
            shareBtnLabel.TextAlignment = UITextAlignment.Center;
            shareBtnLabel.Font          = UIFont.FromName("Montserrat-Bold", 12f);
            shareBtnLabel.TextColor     = UIColor.White;
            buttonBar.Add(shareBtnLabel);

            buttonBar.Add(shareBtn);
            //end share button

            //Create badge icon
            string parsed = Regex.Replace(query[0].bname, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled);


            String q = "SELECT * FROM MagpieUser WHERE bid = " + query[0].bid;

            System.Collections.Generic.List <MagpieUser> userTuple = db.Query <MagpieUser>(q);


            UIButton badgeBtn   = new UIButton(new CoreGraphics.CGRect((float)(UIScreen.MainScreen.Bounds.Width / 2) - 75, 270, 150, 128.89221556886));
            UILabel  badgeLabel = new UILabel(new CGRect(0, 50, badgeBtn.Bounds.Width, badgeBtn.Bounds.Height / 4));

            badgeLabel.UserInteractionEnabled = false;

            if (userTuple.ElementAt(0).isClaimed.Equals("")) //user does not have badge
            {
                if (checkDistance(new CLLocation(query[0].lat, query[0].lon), new CLLocation(map.UserLocation.Location.Coordinate.Latitude, map.UserLocation.Location.Coordinate.Longitude)))
                {
                    //user is within collection distance

                    parsed          = "badges/SSW_" + parsed + ".png";
                    badgeLabel.Text = "COLLECT";
                }
                else
                {
                    parsed          = "graybadges/SSW_" + parsed + ".png";
                    badgeLabel.Text = "MOVE CLOSER";
                }
                badgeLabel.Font            = UIFont.FromName("Montserrat-Bold", 14f);
                badgeLabel.TextColor       = UIColor.White;
                badgeLabel.TextAlignment   = UITextAlignment.Center;
                badgeLabel.BackgroundColor = UIColor.DarkGray.ColorWithAlpha(0.5f);
            }
            else //user has badge
            {
                parsed = "badges/SSW_" + parsed + ".png";
                badgeBtn.UserInteractionEnabled = false;
            }

            UIImageView icon = new UIImageView(UIImage.FromFile(parsed));

            icon.Frame = new CoreGraphics.CGRect((float)(UIScreen.MainScreen.Bounds.Width / 2) - 75, 270, 150, 128.89221556886);
            icon.UserInteractionEnabled = false;

            icon.AddSubview(badgeLabel);

            badgeDetailView.Add(buttonBar);

            badgeBtn.TouchUpInside += (object sender, EventArgs e) =>
            {
                //Collect badge event

                if (checkDistance(new CLLocation(query[0].lat, query[0].lon), new CLLocation(map.UserLocation.Location.Coordinate.Latitude, map.UserLocation.Location.Coordinate.Longitude)))
                {
                    //user can collect
                    badgeLabel.Text            = "";
                    badgeLabel.BackgroundColor = UIColor.Clear;
                    ClaimBadge claim = new ClaimBadge();
                    claim.claimLocalBadge(new CLLocationCoordinate2D(query[0].lat, query[0].lon));
                }
            };

            badgeDetailView.Add(icon);
            badgeDetailView.Add(badgeBtn);
            //Controls the scroll view of the description and artist
            UIScrollView textScroll = new UIScrollView(new System.Drawing.RectangleF(0, 380, (float)UIScreen.MainScreen.Bounds.Width, (float)UIScreen.MainScreen.Bounds.Height - 440));

            textScroll.ScrollEnabled   = true;
            textScroll.BackgroundColor = UIColor.White;

            //Build artist and year description
            UILabel subLabel = new UILabel(new System.Drawing.RectangleF(5, 0, (float)textScroll.Bounds.Width, 40));

            subLabel.Text      = "ARTIST: " + query[0].art.ToUpper();
            subLabel.TextColor = UIColor.LightGray;
            subLabel.Font      = UIFont.FromName("Montserrat-Bold", 16f);

            //Builds the badge description
            UITextView description = new UITextView(new System.Drawing.RectangleF(20, 20, (float)(textScroll.Bounds.Width - 40), (float)textScroll.Bounds.Height));

            description.Add(subLabel);
            description.Text = "\n\n" + query[0].desc;

            description.TextColor = UIColor.Black;
            description.Font      = UIFont.FromName("Montserrat-Regular", 16f);

            textScroll.AddSubview(description);

            badgeDetailView.Add(textScroll);
            //End badge description build


            //show badge detail view controller
            this.NavigationController.PushViewController(badgeDetailView, true);
        }
示例#5
0
    //Generates a Dataset from the OCR result
    void MakeDataset(string text)
    {
        Dataset.Types type      = Dataset.Types.Null;
        string        firstline = text.Substring(0, text.IndexOf("\n"));

        try{
            text = text.Replace(firstline, null);
        } catch {
            resetApp();
        }
        Debug.Log("Title: " + firstline + "\n");
        text = text.TrimStart();

        string ser = text.Substring(0, text.IndexOf("\n"));

        try{
            text = text.Replace(ser, "");
        } catch {
            resetApp();
        }
        string[] tempSer = ser.Split(' ');

        string[] series = new string[tempSer.Length - 1];

        for (int i = 1; i < tempSer.Length; i++)
        {
            series [i - 1] = tempSer [i];
        }

        Debug.Log("Series: " + ser + "\n");
        text = text.TrimStart();



        System.Collections.Generic.List <string[]> tableList    = new System.Collections.Generic.List <string[]>();
        System.Collections.Generic.List <string>   categoryList = new System.Collections.Generic.List <string>();
        string temp    = "";
        bool   success = true;

        const int MIN_LENGTH = 1;

        while (text.Length > MIN_LENGTH && text.IndexOf("\n") > 0)
        {
            temp = text.Substring(0, text.IndexOf("\n"));
            text = text.Replace(temp, "");

            string catName = "";             //The row name

            //Remove the row name by assuming everything until the first digit is the name and removing that from the string.
            for (int x = 0; x < temp.Length; x++)
            {
                if (!Char.IsDigit(temp [x]))
                {
                    catName += temp [x];
                }
                else
                {
                    break;
                }
            }

            try{
                temp = temp.Replace(catName, "");
            } catch {
                resetApp();
            }

            categoryList.Add(catName);

            //Removes series entries from rows
            string[] prescreenRow = temp.Split(' ');
            string[] row          = new string[prescreenRow.Length];

            for (int i = 0; i < prescreenRow.Length; i++)
            {
                if (!prescreenRow [i].All(char.IsDigit))
                {
                    row [i] = StringManipulation.sanitizeString(prescreenRow [i]);
                }
                else
                {
                    row [i] = prescreenRow [i];
                }
            }

            tableList.Add(row);
            Debug.Log("Row: " + string.Join("", tableList.ElementAt(tableList.Count - 1)) + "\n");
            text = text.TrimStart();
        }
        string[] categories = categoryList.ToArray();

        float[,] table = new float[series.Length, tableList.Count];
        for (int i = 0; i < tableList.Count; i++)
        {
            for (int x = 0; x < series.Length; x++)
            {
                float tempFloat = 0;

                try{
                    if (Single.TryParse(tableList.ElementAt(i) [x], out tempFloat))
                    {
                    }
                    else if (Single.TryParse(StringManipulation.sanitizeString(tableList.ElementAt(i) [x]), out tempFloat))
                    {
                    }
                    else
                    {
                        tempFloat = 0;
                        success   = false;
                    }
                }catch (Exception e) {
                    tempFloat = 0;
                    success   = false;
                }

                table [x, i] = tempFloat;
            }
        }

        string dbg = "";

        for (int i = 0; i < tableList.Count; i++)
        {
            dbg  = "";
            dbg += categories [i] + " ";
            for (int x = 0; x < series.Length; x++)
            {
                dbg += " : " + table[x, i];
            }
            Debug.Log(dbg);
        }

        //Send to form
        Dataset dataset = new Dataset(type, firstline, categories, series, "", "", table, categories.Length, series.Length);

        UI.GetComponent <UI> ().initialiseForm(dataset);
        loadScreen.SetActive(false);
        form.SetActive(true);

        //Create graph directly
        //Dataset.dataset = new Dataset (type, firstline, categories, series, tempSer[0], firstline, table, categories.Length, series.Length);
    }
        public void GetUpdateFirmware(ref System.Collections.Generic.List <CFirmwareStation> versionMicros)
        {
            List <CFirmwareStation> versionMicrosHostController = new List <CFirmwareStation>();

            try
            {
                //Carpeta donde guardar la descarga
                string firmwareFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles), "JBC\\JBC Station Controller Service\\Firmwares");

                //Crear carpeta temporal
                if (!(new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.DirectoryExists(firmwareFolder))
                {
                    Directory.CreateDirectory(firmwareFolder);
                }

                //Endpoint HostController
                EndpointAddress ep = null;

                m_mutexHostControllerEndpoints.WaitOne();
                if (m_hostControllerEndpoints.Count > 0)
                {
                    ep = m_hostControllerEndpoints.First();
                }
                m_mutexHostControllerEndpoints.ReleaseMutex();

                if (ep != null)
                {
                    //Open connection
                    BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
                    JBCHostControllerServiceClient serviceClient = new JBCHostControllerServiceClient(binding, ep);
                    serviceClient.Open();

                    //Recorrer todos los micros
                    for (int i = 0; i <= versionMicros.Count - 1; i++)
                    {
                        //Obtener información del firmware
                        HostControllerServiceReference.dc_FirmwareStation infoUpdateFirmware = new HostControllerServiceReference.dc_FirmwareStation();
                        infoUpdateFirmware.model           = System.Convert.ToString(versionMicros.ElementAt(i).Model);
                        infoUpdateFirmware.hardwareVersion = System.Convert.ToString(versionMicros.ElementAt(i).HardwareVersion);

                        List <HostControllerServiceReference.dc_FirmwareStation> listNewInfoUpdateFirmware = new List <HostControllerServiceReference.dc_FirmwareStation>();
                        listNewInfoUpdateFirmware.AddRange(serviceClient.GetInfoUpdateFirmware(infoUpdateFirmware));
                        foreach (HostControllerServiceReference.dc_FirmwareStation dc_firmware in listNewInfoUpdateFirmware)
                        {
                            CFirmwareStation firmware = new CFirmwareStation();
                            firmware.Model           = dc_firmware.model;
                            firmware.ModelVersion    = dc_firmware.modelVersion;
                            firmware.ProtocolVersion = dc_firmware.protocolVersion;
                            firmware.HardwareVersion = dc_firmware.hardwareVersion;
                            firmware.SoftwareVersion = dc_firmware.softwareVersion;
                            firmware.FileName        = Path.Combine(firmwareFolder, dc_firmware.fileName);
                            versionMicrosHostController.Add(firmware);

                            //Si no existe el archivo de firmware
                            if (!File.Exists(firmware.FileName))
                            {
                                bool bOk       = false;
                                bool bContinue = false;
                                int  nSequence = 1;

                                //Download firmware update
                                do
                                {
                                    int nTries = 3;
                                    bOk = false;
                                    dc_UpdateFirmware updateFirmware = new dc_UpdateFirmware();

                                    while (nTries > 0 && !bOk)
                                    {
                                        updateFirmware = serviceClient.GetFileUpdateFirmware(nSequence, dc_firmware.fileName);
                                        bOk            = updateFirmware.sequence == nSequence;
                                        bContinue      = !updateFirmware.final;

                                        nTries--;
                                    }

                                    if (!bOk)
                                    {
                                        break;
                                    }
                                    nSequence++;

                                    (new Microsoft.VisualBasic.Devices.ServerComputer()).FileSystem.WriteAllBytes(firmware.FileName, updateFirmware.bytes, true);
                                } while (bContinue);
                            }
                        }
                    }

                    serviceClient.Close();
                }
            }
            catch (Exception ex)
            {
                LoggerModule.logger.Error(System.Reflection.MethodInfo.GetCurrentMethod().Name + ". Error: " + ex.Message);
            }

            versionMicros = versionMicrosHostController;
        }