aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Managers/RegisteredView.cs
blob: bdf2105a6855eff90491b0501ee3a325e1fd6f91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using Tango.Core.Commands;
using Tango.MachineStudio.Common.Controls;

namespace Tango.MachineStudio.DB.Managers
{
    /// <summary>
    /// Represents a registered MDI child (data table) view
    /// </summary>
    /// <seealso cref="Tango.MachineStudio.Common.Controls.MdiChild" />
    public class RegisteredView : MdiChild
    {
        private static Random rnd = new Random();

        /// <summary>
        /// Adds the view to the display.
        /// </summary>
        public RelayCommand AddCommand { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="RegisteredView"/> class.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="view">The view.</param>
        /// <param name="action">The action.</param>
        public RegisteredView(String header, FrameworkElement view, Action action)
        {
            Location = new Point(rnd.Next(30, 200), rnd.Next(30, 200));
            Icon = PackIconKind.Table;

            if (header.Length < 5)
            {
                header = header.ToUpper();
            }

            Header = header;

            View = view;

            View.MaxWidth = 1500;
            View.MaxHeight = 800;

            if (action != null)
            {
                AddCommand = new RelayCommand(action);
            }
            else
            {
                AddCommand = new RelayCommand(() =>
                {
                    if (!ViewsManager.DisplayedViews.Contains(this))
                    {
                        ViewsManager.DisplayedViews.Add(this);
                        View.BringIntoView();
                        View.Focus();
                    }
                    else
                    {
                        View.BringIntoView();
                        View.Focus();
                    }
                });
            }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="RegisteredView"/> class.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="view">The view.</param>
        public RegisteredView(String header, FrameworkElement view) : this(header, view, null)
        {
            if (header.Length < 5)
            {
                header = header.ToUpper();
            }

            view.MaxWidth = 1500;
            view.MaxHeight = 800;

            Header = header;
            View = view;
        }

        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            return Header;
        }
    }
}
pan class="p">, 0}, }; PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::AuxillaryParseTableField const TableStruct::aux[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ::google::protobuf::internal::AuxillaryParseTableField(), }; PROTOBUF_CONSTEXPR_VAR ::google::protobuf::internal::ParseTable const TableStruct::schema[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { { NULL, NULL, 0, -1, -1, -1, -1, NULL, false }, }; const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { ~0u, // no _has_bits_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CalculateResponse, _internal_metadata_), ~0u, // no _extensions_ ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CalculateResponse, sum_), }; static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { { 0, -1, sizeof(CalculateResponse)}, }; static ::google::protobuf::Message const * const file_default_instances[] = { reinterpret_cast<const ::google::protobuf::Message*>(&_CalculateResponse_default_instance_), }; namespace { void protobuf_AssignDescriptors() { AddDescriptors(); ::google::protobuf::MessageFactory* factory = NULL; AssignDescriptors( "CalculateResponse.proto", schemas, file_default_instances, TableStruct::offsets, factory, file_level_metadata, NULL, NULL); } void protobuf_AssignDescriptorsOnce() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors); } void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD; void protobuf_RegisterTypes(const ::std::string&) { protobuf_AssignDescriptorsOnce(); ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 1); } } // namespace void TableStruct::InitDefaultsImpl() { GOOGLE_PROTOBUF_VERIFY_VERSION; ::google::protobuf::internal::InitProtobufDefaults(); _CalculateResponse_default_instance_._instance.DefaultConstruct(); ::google::protobuf::internal::OnShutdownDestroyMessage( &_CalculateResponse_default_instance_);} void InitDefaults() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &TableStruct::InitDefaultsImpl); } namespace { void AddDescriptorsImpl() { InitDefaults(); static const char descriptor[] GOOGLE_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = { "\n\027CalculateResponse.proto\022\017Tango.PMR.Stu" "bs\" \n\021CalculateResponse\022\013\n\003Sum\030\001 \001(\001B\033\n\031" "com.twine.tango.pmr.stubsb\006proto3" }; ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( descriptor, 113); ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( "CalculateResponse.proto", &protobuf_RegisterTypes); } } // anonymous namespace void AddDescriptors() { static GOOGLE_PROTOBUF_DECLARE_ONCE(once); ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl); } // Force AddDescriptors() to be called at dynamic initialization time. struct StaticDescriptorInitializer { StaticDescriptorInitializer() { AddDescriptors(); } } static_descriptor_initializer; } // namespace protobuf_CalculateResponse_2eproto // =================================================================== #if !defined(_MSC_VER) || _MSC_VER >= 1900 const int CalculateResponse::kSumFieldNumber; #endif // !defined(_MSC_VER) || _MSC_VER >= 1900 CalculateResponse::CalculateResponse() : ::google::protobuf::Message(), _internal_metadata_(NULL) { if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) { protobuf_CalculateResponse_2eproto::InitDefaults(); } SharedCtor(); // @@protoc_insertion_point(constructor:Tango.PMR.Stubs.CalculateResponse) } CalculateResponse::CalculateResponse(const CalculateResponse& from) : ::google::protobuf::Message(), _internal_metadata_(NULL), _cached_size_(0) { _internal_metadata_.MergeFrom(from._internal_metadata_); sum_ = from.sum_; // @@protoc_insertion_point(copy_constructor:Tango.PMR.Stubs.CalculateResponse) } void CalculateResponse::SharedCtor() { sum_ = 0; _cached_size_ = 0; } CalculateResponse::~CalculateResponse() { // @@protoc_insertion_point(destructor:Tango.PMR.Stubs.CalculateResponse) SharedDtor(); } void CalculateResponse::SharedDtor() { } void CalculateResponse::SetCachedSize(int size) const { GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); } const ::google::protobuf::Descriptor* CalculateResponse::descriptor() { protobuf_CalculateResponse_2eproto::protobuf_AssignDescriptorsOnce(); return protobuf_CalculateResponse_2eproto::file_level_metadata[kIndexInFileMessages].descriptor; } const CalculateResponse& CalculateResponse::default_instance() { protobuf_CalculateResponse_2eproto::InitDefaults(); return *internal_default_instance(); } CalculateResponse* CalculateResponse::New(::google::protobuf::Arena* arena) const { CalculateResponse* n = new CalculateResponse; if (arena != NULL) { arena->Own(n); } return n; } void CalculateResponse::Clear() { // @@protoc_insertion_point(message_clear_start:Tango.PMR.Stubs.CalculateResponse) ::google::protobuf::uint32 cached_has_bits = 0; // Prevent compiler warnings about cached_has_bits being unused (void) cached_has_bits; sum_ = 0; _internal_metadata_.Clear(); } bool CalculateResponse::MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) { #define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure ::google::protobuf::uint32 tag; // @@protoc_insertion_point(parse_start:Tango.PMR.Stubs.CalculateResponse) for (;;) { ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u); tag = p.first; if (!p.second) goto handle_unusual; switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { // double Sum = 1; case 1: { if (static_cast< ::google::protobuf::uint8>(tag) == static_cast< ::google::protobuf::uint8>(9u /* 9 & 0xFF */)) { DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>( input, &sum_))); } else { goto handle_unusual; } break; } default: { handle_unusual: if (tag == 0) { goto success; } DO_(::google::protobuf::internal::WireFormat::SkipField( input, tag, _internal_metadata_.mutable_unknown_fields())); break; } } } success: // @@protoc_insertion_point(parse_success:Tango.PMR.Stubs.CalculateResponse) return true; failure: // @@protoc_insertion_point(parse_failure:Tango.PMR.Stubs.CalculateResponse) return false; #undef DO_ } void CalculateResponse::SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const { // @@protoc_insertion_point(serialize_start:Tango.PMR.Stubs.CalculateResponse) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // double Sum = 1; if (this->sum() != 0) { ::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->sum(), output); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { ::google::protobuf::internal::WireFormat::SerializeUnknownFields( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), output); } // @@protoc_insertion_point(serialize_end:Tango.PMR.Stubs.CalculateResponse) } ::google::protobuf::uint8* CalculateResponse::InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const { (void)deterministic; // Unused // @@protoc_insertion_point(serialize_to_array_start:Tango.PMR.Stubs.CalculateResponse) ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; // double Sum = 1; if (this->sum() != 0) { target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->sum(), target); } if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance()), target); } // @@protoc_insertion_point(serialize_to_array_end:Tango.PMR.Stubs.CalculateResponse) return target; } size_t CalculateResponse::ByteSizeLong() const { // @@protoc_insertion_point(message_byte_size_start:Tango.PMR.Stubs.CalculateResponse) size_t total_size = 0; if ((_internal_metadata_.have_unknown_fields() && ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) { total_size += ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( (::google::protobuf::internal::GetProto3PreserveUnknownsDefault() ? _internal_metadata_.unknown_fields() : _internal_metadata_.default_instance())); } // double Sum = 1; if (this->sum() != 0) { total_size += 1 + 8; } int cached_size = ::google::protobuf::internal::ToCachedSize(total_size); GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); _cached_size_ = cached_size; GOOGLE_SAFE_CONCURRENT_WRITES_END(); return total_size; } void CalculateResponse::MergeFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_merge_from_start:Tango.PMR.Stubs.CalculateResponse) GOOGLE_DCHECK_NE(&from, this); const CalculateResponse* source = ::google::protobuf::internal::DynamicCastToGenerated<const CalculateResponse>( &from); if (source == NULL) { // @@protoc_insertion_point(generalized_merge_from_cast_fail:Tango.PMR.Stubs.CalculateResponse) ::google::protobuf::internal::ReflectionOps::Merge(from, this); } else { // @@protoc_insertion_point(generalized_merge_from_cast_success:Tango.PMR.Stubs.CalculateResponse) MergeFrom(*source); } } void CalculateResponse::MergeFrom(const CalculateResponse& from) { // @@protoc_insertion_point(class_specific_merge_from_start:Tango.PMR.Stubs.CalculateResponse) GOOGLE_DCHECK_NE(&from, this); _internal_metadata_.MergeFrom(from._internal_metadata_); ::google::protobuf::uint32 cached_has_bits = 0; (void) cached_has_bits; if (from.sum() != 0) { set_sum(from.sum()); } } void CalculateResponse::CopyFrom(const ::google::protobuf::Message& from) { // @@protoc_insertion_point(generalized_copy_from_start:Tango.PMR.Stubs.CalculateResponse) if (&from == this) return; Clear(); MergeFrom(from); } void CalculateResponse::CopyFrom(const CalculateResponse& from) { // @@protoc_insertion_point(class_specific_copy_from_start:Tango.PMR.Stubs.CalculateResponse) if (&from == this) return; Clear(); MergeFrom(from); } bool CalculateResponse::IsInitialized() const { return true; } void CalculateResponse::Swap(CalculateResponse* other) { if (other == this) return; InternalSwap(other); } void CalculateResponse::InternalSwap(CalculateResponse* other) { using std::swap; swap(sum_, other->sum_); _internal_metadata_.Swap(&other->_internal_metadata_); swap(_cached_size_, other->_cached_size_); } ::google::protobuf::Metadata CalculateResponse::GetMetadata() const { protobuf_CalculateResponse_2eproto::protobuf_AssignDescriptorsOnce(); return protobuf_CalculateResponse_2eproto::file_level_metadata[kIndexInFileMessages]; } #if PROTOBUF_INLINE_NOT_IN_HEADERS // CalculateResponse // double Sum = 1; void CalculateResponse::clear_sum() { sum_ = 0; } double CalculateResponse::sum() const { // @@protoc_insertion_point(field_get:Tango.PMR.Stubs.CalculateResponse.Sum) return sum_; } void CalculateResponse::set_sum(double value) { sum_ = value; // @@protoc_insertion_point(field_set:Tango.PMR.Stubs.CalculateResponse.Sum) } #endif // PROTOBUF_INLINE_NOT_IN_HEADERS // @@protoc_insertion_point(namespace_scope) } // namespace Stubs } // namespace PMR } // namespace Tango // @@protoc_insertion_point(global_scope)