Exemplo n.º 1
0
        private static void SetXDataAndMoveToLocation(
            Entity ent, ResultBuffer rbdata, Point3d pt
            )
        {
            Database db =
                Application.DocumentManager.MdiActiveDocument.Database;
            Transaction tr = db.TransactionManager.StartTransaction();

            using (tr)
            {
                ent =
                    tr.GetObject(ent.ObjectId, OpenMode.ForWrite) as Entity;

                // Let's add our message information as XData,
                // for later editing

                RbEncoder.AddRegAppTableRecord(APPLICATION_PREFIX);
                ResultBuffer rb = rbdata;
                ent.XData = rb;
                rb.Dispose();

                // Move to the correct location

                Matrix3d disp = Matrix3d.Displacement(pt.GetAsVector());
                ent.TransformBy(disp);

                tr.Commit();
            }
        }
Exemplo n.º 2
0
        // Get the data for a contact and encode it

        private static string GetContactData(
            Editor ed, ResultBuffer defs, out ResultBuffer rb
            )
        {
            // Name is mandatory

            object defName = GetDefault("Name", defs);
            string name    =
                GetMandatoryString(ed, "Name", defName);

            // All other fields are optional

            object defPhone = GetDefault("Phone", defs);
            string phone    =
                GetOptionalString(ed, "Phone number", defPhone);

            object defEmail = GetDefault("Email", defs);
            string email    =
                GetOptionalString(ed, "Email address", defEmail);

            object defAddress = GetDefault("Address", defs);
            string address    =
                GetOptionalString(ed, "Address", defAddress);

            object defAddress2 = GetDefault("Address2", defs);
            string address2    =
                GetOptionalString(ed, "Address 2", defAddress2);

            object defWebsite = GetDefault("Website", defs);
            string website    =
                GetOptionalString(ed, "Website", defWebsite);

            object defMemo = GetDefault("Memo", defs);
            string memo    =
                GetOptionalString(ed, "Memo", defMemo);

            // Create XData to store these input values

            rb = RbEncoder.CreateContactRb(
                name, phone, email, address, address2,
                website, memo
                );

            // Encode the data into a URL to generate a QR Code

            return(FormatDataHelper.EncodeContact(
                       name, phone, email, address,
                       address2, website, memo
                       ));
        }
Exemplo n.º 3
0
        // Get the data for a URL and encode it

        private static string GetUrlData(
            Editor ed, ResultBuffer defs, out ResultBuffer rb
            )
        {
            object defUrl = GetDefault("UValue", defs);
            string url    = GetMandatoryString(ed, "Url", defUrl);

            // Create XData to store the input value

            rb = RbEncoder.CreateUrlRb(url);

            // Encode the data into a URL to generate a QR Code

            return(FormatDataHelper.EncodeUrl(url));
        }
Exemplo n.º 4
0
        // Get the data for some text and encode it

        private static string GetTextData(
            Editor ed, ResultBuffer defs, out ResultBuffer rb
            )
        {
            object defText = GetDefault("TValue", defs);
            string text    = GetMandatoryString(ed, "Text", defText);

            // Create XData to store the input value

            rb = RbEncoder.CreateTextRb(text);

            // Encode the data into a URL to generate a QR Code

            return(FormatDataHelper.EncodeText(text));
        }
Exemplo n.º 5
0
        // Get the data for a phone number and encode it

        private static string GetPhoneData(
            Editor ed, ResultBuffer defs, out ResultBuffer rb
            )
        {
            object defPhone = GetDefault("PValue", defs);
            string phone    =
                GetMandatoryString(ed, "Phone number", defPhone);

            // Create XData to store the input value

            rb = RbEncoder.CreatePhoneRb(phone);

            // Encode the data into a URL to generate a QR Code

            return(FormatDataHelper.EncodePhone(phone));
        }
Exemplo n.º 6
0
        // Get the data for an email address and encode it

        private static string GetEmailData(
            Editor ed, ResultBuffer defs, out ResultBuffer rb
            )
        {
            object defEmail = GetDefault("EValue", defs);
            string email    =
                GetMandatoryString(ed, "Email address", defEmail);

            // Create XData to store the input value

            rb = RbEncoder.CreateEmailRb(email);

            // Encode the data into a URL to generate a QR Code

            return(FormatDataHelper.EncodeEmail(email));
        }
Exemplo n.º 7
0
        // Get the data for a calendar event and encode it

        private static string GetCalendarData(
            Editor ed, ResultBuffer defs, out ResultBuffer rb
            )
        {
            // Title is mandatory

            object defTitle = GetDefault("Title", defs);
            string title    =
                GetMandatoryString(ed, "Event title", defTitle);

            // All other fields are optional

            object   defStart = GetDefault("Start", defs);
            DateTime start    =
                GetMandatoryDateTime(ed, "Start date & time", defStart);

            object   defEnd = GetDefault("End", defs);
            DateTime end    =
                GetOptionalDateTime(ed, "End date & time", defEnd);

            object defLocation = GetDefault("Location", defs);
            string location    =
                GetOptionalString(ed, "Location", defLocation);

            object defDesc = GetDefault("Description", defs);
            string desc    =
                GetOptionalString(ed, "Description", defDesc);

            // Create XData to store these input values

            rb = RbEncoder.CreateCalendarRb(
                title, start, end, location, desc
                );

            // Encode the data into a URL to generate a QR Code

            return(FormatDataHelper.EncodeCalendar(
                       title, start, end, location, desc
                       ));
        }
Exemplo n.º 8
0
        // Get the data for a geo-location and encode it

        private static string GetGeolocationData(
            Editor ed, ResultBuffer defs, out ResultBuffer rb
            )
        {
            object defLat = GetDefault("Lat", defs);
            double lat    =
                GetMandatoryDouble(ed, "Latitude", defLat);

            object defLng = GetDefault("Lat", defs);
            double lng    =
                GetMandatoryDouble(ed, "Longitude", defLng);

            object defQuery = GetDefault("Query", defs);
            string query    =
                GetOptionalString(ed, "Query", defQuery);

            // Create XData to store these input values

            rb = RbEncoder.CreateGeolocationRb(lat, lng, query);

            // Encode the data into a URL to generate a QR Code

            return(FormatDataHelper.EncodeGeolocation(lat, lng, query));
        }