Exemple #1
0
        /// <summary>
        /// Reset the text annotation position.
        /// </summary>
        public override void Reposition()
        {
            if (horizontalAxis != null && verticalAxis != null)
            {
                textRectangle.X = (int)(Position.X * horizontalAxis.WidthRate + ParentControl.Padding.Left + horizontalAxis.Center);
                textRectangle.Y = (int)(-Position.Y * verticalAxis.HeightRate + ParentControl.Padding.Top + verticalAxis.Center);
            }
            else
            {
                if (IsRelativePositionX)
                {
                    textRectangle.X = (int)(relateRateX * ParentControl.Width);     // (int)position.X;
                }
                else
                {
                    textRectangle.X = (int)position.X;
                }
                if (IsRelativePositionX)
                {
                    textRectangle.Y = (int)(relateRateY * ParentControl.Height);     // (int)position.X;
                }
                else
                {
                    textRectangle.Y = (int)position.Y;
                }
            }
            textRectangle.Height = (int)rSize.Height;
            textRectangle.Width  = (int)rSize.Width;

            ParentControl.ReDrawLayer(DrawingLayer);
        }
Exemple #2
0
            public MultiDiagramDocViewControl(MultiDiagramDocView docView)
            {
                DocView = docView;

                Control parentControl = new ParentControl(this);

                parentControl.SuspendLayout();
                base.SuspendLayout();
                parentControl.Controls.Add(this);

                base.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
                base.SetStyle(ControlStyles.Selectable, false);

                base.Dock      = DockStyle.Fill;
                base.Alignment = TabAlignment.Bottom;
                base.DrawMode  = TabDrawMode.OwnerDrawFixed;
                base.Padding   = new Point(TabOutsideBorderLength + TabInsideBorderLength, TabOutsideBorderLength + TabInsideBorderLength);
                base.HotTrack  = false;
                base.TabStop   = false;

                Microsoft.Win32.SystemEvents.UserPreferenceChanged += SetFonts;
                SetFonts(null, null);

                base.AllowDrop = true;
                Timer activateTimer = new Timer();

                activateTimer.Interval = SystemInformation.DoubleClickTime;
                activateTimer.Tick    += new EventHandler(ActivateTimer_Tick);
                myDragActivateTabIndex = -1;
                myDragActivateTimer    = activateTimer;

                base.ResumeLayout(false);
                parentControl.ResumeLayout(false);
            }
        /// <summary>
        /// Reset the annotation position.
        /// </summary>
        public override void Reposition()
        {
            if (horizontalAxis != null && verticalAxis != null)
            {
                rectangle.X      = startValuePoint.X * horizontalAxis.WidthRate + ParentControl.Padding.Left + horizontalAxis.Center;
                rectangle.Y      = -startValuePoint.Y * verticalAxis.HeightRate + ParentControl.Padding.Top + verticalAxis.Center;
                rectangle.Height = -(endValuePoint.Y - startValuePoint.Y) * verticalAxis.HeightRate;
                rectangle.Width  = (endValuePoint.X - startValuePoint.X) * horizontalAxis.WidthRate;
            }
            else
            {
                rectangle.X      = startValuePoint.X * ParentControl.DrawWidth + ParentControl.Padding.Left;
                rectangle.Y      = (1 - startValuePoint.Y) * ParentControl.DrawHeight + ParentControl.Padding.Top;
                rectangle.Height = -(endValuePoint.Y - startValuePoint.Y) * ParentControl.DrawHeight;
                rectangle.Width  = (endValuePoint.X - startValuePoint.X) * ParentControl.DrawWidth;
            }
            if (rectangle.Width < 0)
            {
                rectangle.Width *= -1;
                rectangle.X     -= rectangle.Width;
            }
            if (rectangle.Height < 0)
            {
                rectangle.Height *= -1;
                rectangle.Y      -= rectangle.Height;
            }

            ParentControl.ReDrawLayer(DrawingLayer);
        }
Exemple #4
0
        public void Adding_Child_Should_Call_PropertyChanged_If_Parent_Value_Changed()
        {
            bool   called   = false;
            string oldValue = null;
            string newValue = null;

            ParentControl parent = new ParentControl();

            parent.Test = "bar";

            ChildControl child = new ChildControl();

            propertyChangedCallback = (s, o, n) =>
            {
                called   = s == child;
                oldValue = o;
                newValue = n;
            };

            parent.Children.Add(child);

            Assert.IsTrue(called);
            Assert.AreEqual(oldValue, "foo");
            Assert.AreEqual(newValue, "bar");
        }
        private void NetworkHandler_NetworkInitializingFinished(InitializeNetworkHandler handler)
        {
            try
            {
                handler.NetworkInitializingFinished -= NetworkHandler_NetworkInitializingFinished;

                ConnectionLobby.Status = handler.Message;

                if (!handler.Error)
                {
                    Network = handler.Network;

                    SessionInformation = new SessionConnectParameters(handler.ConnectParameters.ServerIP, ParentControl.NetworkDeathHandler, Network.ClientSession);
                    ShowReconnectOptions();

                    if (handler.ConnectParameters.GameReconnect)
                    {
                        ParentControl.StatusControl.SetReconnecting();
                        ParentControl.SwitchMode(GameMode.Status);
                    }
                    else
                    {
                        ParentControl.OptionControl.SetServerIP(handler.ConnectParameters.ServerIP.ToString());
                        ParentControl.SwitchMode(GameMode.Options);
                    }
                }
            }
            finally
            {
                Connecting = false;
            }
        }
        public void CancelBtnClicked(object sender, EventArgs e)
        {
            if (ChangesMade() == false)
            {
                // No edit is done.
                // No need to show messageBox.
                ShowSelectionGroupBox();
                return;
            }

            var result = ParentControl.ShowDialog(
                "Discard the changes to config?",
                MsgBoxIcon.Warning,
                "",
                DefaultButton.Button1,
                "Discard", "Save", "Cancel");

            if (result == MsgBoxResult.Button1)
            {
                ShowSelectionGroupBox();
            }
            else if (result == MsgBoxResult.Button2)
            {
                SaveConfig(this, EventArgs.Empty);
            }
        }
        public void DeleteConfig(object sender, EventArgs e)
        {
            var reg = SelectedRegistration;

            if (reg == null)
            {
                return;
            }

            var configs = profiles.AcConfigs;
            var item    = configs.Find(reg);
            var path    = item.FilePath;
            var ac      = item.Config.AC;

            var result = ParentControl.ShowDialog(
                $"Permanently delete {reg} ({ac}) ?",
                MsgBoxIcon.Warning,
                "",
                DefaultButton.Button2,
                "Delete", "Cancel");

            if (result == MsgBoxResult.Button1 && TryDeleteConfig(path))
            {
                configs.Remove(reg);
                AddToDeletedDefaultAc(path, reg);
                ReadShadowedProfile(reg);
                RefreshListView();
                AircraftsChanged?.Invoke(this, EventArgs.Empty);
            }
        }
Exemple #8
0
 /// <summary>
 /// Re draw the parent chart area.
 /// </summary>
 protected void ReDraw()
 {
     if (ParentControl != null)
     {
         ParentControl.Draw();
     }
 }
 private void IntiializeDelayedCancel()
 {
     StatusLobby.SetError();
     Timeout.Reset();
     CancelTimer.Restart();
     ParentControl.Disconnect();
 }
        public void FinishEdit()
        {
            if (Node != null)
            {
                var oldName = Text;
                var newName = Editor.UIText;
                if (!oldName.Equals(newName))
                {
                    Node.Name = newName;
                    ((INodeProperties)Node.NodeProperties).EndEdit();
                    if (Node.Name == null)
                    {
                        ParentControl.NodeText.Text = newName;
                    }
                }
                if (ParentControl.ParentSurface.Selector.NodeControls.Any() && !ParentControl.ParentSurface.Selector.IsMultiSelect)
                {
                    ParentControl.ParentSurface.Selector.NodeControls.First().Focus();
                }
                else
                {
                    ParentControl.Focus();
                }

                UnlinkNodeControl();
            }
        }
Exemple #11
0
 internal void Invalidate(int x, int y, int w, int h)
 {
     if (!OutputSuspended)
     {
         ParentControl.GuiInvalidate(x - WindowLeft, y - WindowTop, w, h);
     }
 }
Exemple #12
0
 /// <summary>
 /// When the find form is being closed we record the user-changable settings for later restoration
 /// </summary>
 private void findForm_Closing(object sender, CancelEventArgs e)
 {
     formRestoreData = new MemoryStream();
     findForm.GetRestoreData(formRestoreData, new BinaryFormatter());
     findForm = null;
     ParentControl.Focus(); // This is required if an InforForm has been shown.
     // Otherwise, focus is orphaned. I am not sure why.
 }
        //public static TextPointer GetTextPointAt(TextPointer from, int pos)
        //{
        //    TextPointer ret = from;
        //    int i = 0;

        //    while ((i < pos) && (ret != null))
        //    {
        //        if ((ret.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.Text) || (ret.GetPointerContext(LogicalDirection.Backward) == TextPointerContext.None))
        //        {
        //            i++;
        //        }

        //        if (ret.GetPositionAtOffset(1, LogicalDirection.Forward) == null)
        //            return ret;
        //        ret = ret.GetPositionAtOffset(1, LogicalDirection.Forward);

        //    }

        //    return ret;
        //}
        //private void AddNoteAfterOpenFile()
        //{
        //    foreach (var note in ParentControl.NotesBrowser.Notes)
        //    {
        //        int start = note.Value.OffsetStart;
        //        int end = note.Value.OffsetEnd;
        //        int dif = 0;
        //        foreach (var not in ParentControl.NotesBrowser.Notes)
        //        {
        //            if (not.Key == note.Key) { break; }
        //            if (not.Value.OffsetStart < start) dif++;
        //        }
        //        start += dif;
        //        end += dif;
        //        TextPointer startPointer = ParentControl.TextBox.MainControl.Document.ContentStart;
        //        TextPointer startPos = GetTextPointAt(startPointer, start);
        //        TextPointer endPos = GetTextPointAt(startPointer, end);
        //        new TextRange(startPos, endPos).ApplyPropertyValue(TextElement.BackgroundProperty, System.Windows.Media.Brushes.PaleGreen);
        //        var tempImage = Properties.Resources.noteFlag;
        //        var ScreenCapture = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
        //  tempImage.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(20, 20));

        //        System.Windows.Controls.Image image = new System.Windows.Controls.Image();
        //        image.Source = ScreenCapture;
        //        image.Stretch = Stretch.Fill;
        //        image.Cursor = Cursors.Hand;
        //        image.Height = 14;
        //        image.Width = 14;
        //        image.Tag = note.Key;
        //        image.MouseUp += NoteFlag_MouseUp;
        //        TextPointer p = startPos;
        //        ParentControl.TextBox.MainControl.BeginChange();
        //        InlineUIContainer imageContainer = new InlineUIContainer(image, p);
        //        ParentControl.TextBox.MainControl.EndChange();
        //        ParentControl.TextBox.MainControl.Focus();
        //    }
        //}

        private void NoteFlag_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var item = sender as System.Windows.Controls.Image;

            if (item != null)
            {
                ParentControl.ClickOnFlag(item.Tag.ToString());
            }
        }
Exemple #14
0
 public void Refresh()
 {
     if (!OutputSuspended)
     {
         ParentControl.GuiInvalidate();
         ParentControl.GuiUpdateVertScrollBarPos();
         ParentControl.GuiUpdateHoriScrollBarPos();
         dirty = false;
     }
 }
Exemple #15
0
 public bool ParentExpended()
 {
     if (ParentControl != null)
     {
         return(ParentControl.isExpanded && ParentControl.ParentExpended());
     }
     else
     {
         return(true);
     }
 }
Exemple #16
0
 private void TextEditor1_TextChanged(object sender, EventArgs e)
 {
     if (_isChange)
     {
         return;
     }
     if (null != ParentControl)
     {
         ParentControl.RaiseTextChanged();
     }
 }
 private void AddToDeletedDefaultAc(string path, string reg)
 {
     if (Paths.PathsAreSame(Path.GetDirectoryName(path), ConfigLoader.DefaultFolderPath))
     {
         var deleted = new DeletedDefaultAc();
         var succeed = deleted.Add(reg);
         if (!succeed)
         {
             ParentControl.ShowError(deleted.ErrorMessage);
         }
     }
 }
 private AircraftConfigItem TryValidate()
 {
     try
     {
         return(new AcConfigValidator(elem).Validate());
     }
     catch (InvalidUserInputException ex)
     {
         ParentControl.ShowWarning(ex.Message);
         return(null);
     }
 }
        private void HandleInitResponse(ServerInitializeGameResponse initResponse)
        {
            if (initResponse.m_players == null || initResponse.m_ball == null || initResponse.m_field == null)
            {
                IntiializeDelayedCancel();
                StatusLobby.SetStatus("Invalid server response!");
                return;
            }

            ParentControl.GameControl.InitializeGame(initResponse.m_players, initResponse.m_field, initResponse.m_ball);
            ParentControl.SwitchMode(GameMode.Game);
        }
        private void LabeledRevisionsLV_onMaxScroll(object sender, ScrollEventArgs e)
        {
            if ((maxItems > 0) && (LabeledRevisionsLV.Items.Count >= maxItems))
            {
                maxItems += (int)Preferences.LocalSettings.GetInt("Number_specs", 100);

                if (ParentControl != null)
                {
                    ParentControl.setFiles();
                }
            }
        }
 private string TryGetFileName()
 {
     try
     {
         return(GetFileName());
     }
     catch (NoFileNameAvailException)
     {
         // FileNameGenerator cannot generate a file name.
         ParentControl.ShowError("Failed to save config file.");
         return(null);
     }
 }
 private bool TryDeleteConfig(string path)
 {
     try
     {
         File.Delete(path);
         return(true);
     }
     catch
     {
         ParentControl.ShowError("Failed to delete the selected config.");
         return(false);
     }
 }
Exemple #23
0
 /// <summary>
 /// Called when the toolbar overflow button is unchecked.
 /// </summary>
 /// <param name="sender">The button object.</param>
 /// <param name="e">This parameter is not used.</param>
 protected virtual void OnOverflowButtonUnchecked(object sender, RoutedEventArgs e)
 {
     if (sender is ToggleButton OverflowButton)
     {
         if (OverflowButton.Parent is FrameworkElement ParentControl)
         {
             if (ParentControl.FindName("AddRemoveButton") is ToggleButton AddRemoveButton)
             {
                 AddRemoveButton.IsChecked = false;
                 AddRemoveButton.IsEnabled = true;
             }
         }
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string type   = cmbType.SelectedItem.ToString();
            string prefix = txtPrefix.Text.Trim();
            string name   = txtName.Text.Trim();

            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show("Name cannot be empty.", "Cannot Save Functiond Id", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtName.Focus();
                return;
            }

            if (string.IsNullOrEmpty(prefix))
            {
                MessageBox.Show("Prefix cannot be empty.", "Cannot Save Functiond Id", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtPrefix.Focus();
                return;
            }

            if (this.Model.FunctionalIds.FunctionalId.Any(functionalId => functionalId.Name == name))
            {
                MessageBox.Show($"Name \"{name}\" already exists.", "Cannot Save Functiond Id", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtName.Focus();
                return;
            }

            if (this.Model.FunctionalIds.FunctionalId.Any(functionalId => functionalId.Value == prefix))
            {
                MessageBox.Show($"Prefix \"{prefix}\" already exists.", "Cannot Save Functiond Id", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txtPrefix.Focus();
                return;
            }

            FunctionalId funcId = new FunctionalId(Model);

            funcId.Type  = type;
            funcId.Value = prefix;
            funcId.Name  = name;
            funcId.Guid  = Model.GenerateGuid(name).ToString();

            this.Model.FunctionalIds.FunctionalId.Add(funcId);
            string displayName = string.Concat(string.Concat(name, " - "), prefix);

            ParentControl.RefreshEntity();
            ParentControl.FunctionalIdComboBox.SelectedIndex = ParentControl.FunctionalIdComboBox.FindStringExact(displayName);
            this.Close();

            MessageBox.Show("Functional Id saved in memory.", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #25
0
        void SetLabelsSize()
        {
            string str = " ";

            foreach (AxisLabel aL in labelsCollection)
            {
                if (aL.Text[0].Length > str.Length)
                {
                    str = aL.Text[0];
                }
            }
            SizeF sf = ParentControl.CreateGraphics().MeasureString(str, Font);

            labelSize = new Size((int)sf.Width, (int)sf.Height);
        }
        private void DeleteCurrentConfigFile()
        {
            var file = currentConfig.FilePath;

            try
            {
                File.Delete(file);
            }
            catch (Exception e)
            {
                LoggerInstance.Log(e);
                ParentControl.ShowWarning("The config was saved but the old config cannot" +
                                          $"be deleted. Please manually delete {Path.GetFullPath(file)}.");
            }
        }
Exemple #27
0
        public KeyInfo ReadKey(bool echo)
        {
            if (dirty)
            {
                Refresh();
            }

            while (true)
            {
                var info = ParentControl.ReadKey();
                if (info == null)
                {
                    continue;
                }

                object handler;
                if (scrollHandlers.TryGetValue(info.KeyData, out handler))
                {
                    if (handler is ScrollHandler)
                    {
                        var handled = ((ScrollHandler)handler)();
                        if (handled)
                        {
                            continue;
                        }
                    }
                    else if (handler is MouseHandler)
                    {
                        var handled = ((MouseHandler)handler)(info.MouseCol, info.MouseRow, info.MouseWheel);
                        if (handled)
                        {
                            continue;
                        }
                    }
                }

                if (echo && info.KeyChar != 0)
                {
                    ScrollIntoView(false);
                    Write(info.KeyChar);
                    return(info);
                }
                else
                {
                    return(info);
                }
            }
        }
        private void ApplyConfiguration()
        {
            switch (GameOptionLobby.SelectedOption)
            {
            case RequestOptions.Matchmaking:
                ParentControl.RegistrationControl.MaxPlayers = GameOptionLobby.PlayerCount;
                ParentControl.RegistrationControl.ResetSelection();
                ParentControl.SwitchMode(GameMode.Registration);
                break;

            case RequestOptions.Observe:
                Network.SendClientObserve(GameOptionLobby.PlayerCount);
                ParentControl.SwitchMode(GameMode.Status);
                break;
            }
        }
Exemple #29
0
        public void UpdateRangeOnNotes()
        {
            foreach (var note in ParentControl.NotesBrowser.Notes)
            {
                var end =
                    ParentControl.TextBox.MainControl.Document.ContentStart.GetPositionAtOffset(note.Value.OffsetEnd);
                note.Value.Range = new TextRange(
                    ParentControl.TextBox.MainControl.Document.ContentStart.GetPositionAtOffset(note.Value.OffsetStart),
                    end != null ? end : ParentControl.TextBox.MainControl.Document.ContentEnd);
                var pointer = ParentControl.AddFlag(note.Value.Range, note.Value.Name);
                if (note.Value.Range.Start != pointer)
                {
                    note.Value.Range = new TextRange(pointer, note.Value.Range.End);
                }
            }

            //byte[] flag = NotesBrowser.getJPGFromImageControl(Properties.Resources.noteFlag);
            //for (TextPointer position = note.Value.Range.Start; position != null && position.CompareTo(note.Value.Range.End) != 1; position = position.GetNextContextPosition(LogicalDirection.Forward))
            //{
            //    InlineUIContainer element = position.Parent as InlineUIContainer;
            //    if (element != null && element.Child is System.Windows.Controls.Image)
            //    {
            //        var image = element.Child as System.Windows.Controls.Image;
            //        if (image == null) continue;
            //        var imageSourse = image.Source as System.Windows.Media.ImageSource;
            //        if (imageSourse == null) continue;
            //        byte[] byt = NotesBrowser.getJPGFromImageControl(imageSourse);
            //        //сравнивает картинки
            //        if (byt.Length == flag.Length)
            //        {
            //            bool isflag = true;
            //            for (int t = 0; t < byt.Length; t++)
            //            {
            //                if (byt[t] != flag[t]) { isflag = false; break; }
            //            }
            //            if (!isflag) continue;
            //            image.Cursor = Cursors.Hand;
            //            image.Tag = note.Key;
            //            image.MouseUp += NoteFlag_MouseUp;
            //            element.Unloaded += Element_Unloaded;
            //            //new TextRange(element.ContentStart, element.ContentEnd).Text = string.Empty;
            //        }
            //    }
            //}
        }
Exemple #30
0
        /// <summary>
        ///     Called when the toolbar overflow button is unchecked.
        /// </summary>
        /// <param name="sender">The button object</param>
        /// <param name="e">This parameter is not used</param>
        protected virtual void OnOverflowButtonUnchecked(object sender, RoutedEventArgs e)
        {
            ToggleButton OverflowButton;

            if ((OverflowButton = sender as ToggleButton) != null)
            {
                FrameworkElement ParentControl;
                if ((ParentControl = OverflowButton.Parent as FrameworkElement) != null)
                {
                    ToggleButton AddRemoveButton;
                    if ((AddRemoveButton = ParentControl.FindName("AddRemoveButton") as ToggleButton) != null)
                    {
                        AddRemoveButton.IsChecked = false;
                        AddRemoveButton.IsEnabled = true;
                    }
                }
            }
        }
        public void Adding_Child_Should_Not_Call_PropertyChanged_If_Parent_Value_Unchanged()
        {
            bool called = false;
            string oldValue = null;
            string newValue = null;

            ParentControl parent = new ParentControl();

            ChildControl child = new ChildControl();

            propertyChangedCallback = (s, o, n) =>
            {
                called = s == child;
                oldValue = o;
                newValue = n;
            };

            parent.Children.Add(child);

            Assert.IsFalse(called);
        }
        public void Setting_Parent_Value_Should_Call_PropertyChanged_If_Child_Value_Unset()
        {
            bool called = false;
            string oldValue = null;
            string newValue = null;

            ParentControl parent = new ParentControl();
            ChildControl child = new ChildControl();
            parent.Children.Add(child);

            propertyChangedCallback = (s, o, n) =>
            {
                called = s == child;
                oldValue = o;
                newValue = n;
            };

            parent.Test = "bar";

            Assert.IsTrue(called);
            Assert.AreEqual(oldValue, "foo");
            Assert.AreEqual(newValue, "bar");
        }
			public MultiDiagramDocViewControl(MultiDiagramDocView docView)
			{
				DocView = docView;

				Control parentControl = new ParentControl(this);
				parentControl.SuspendLayout();
				base.SuspendLayout();
				parentControl.Controls.Add(this);

				base.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true);
				base.SetStyle(ControlStyles.Selectable, false);

				base.Dock = DockStyle.Fill;
				base.Alignment = TabAlignment.Bottom;
				base.DrawMode = TabDrawMode.OwnerDrawFixed;
				base.Padding = new Point(TabOutsideBorderLength + TabInsideBorderLength, TabOutsideBorderLength + TabInsideBorderLength);
				base.HotTrack = false;
				base.TabStop = false;

				Microsoft.Win32.SystemEvents.UserPreferenceChanged += SetFonts;
				SetFonts(null, null);

				base.AllowDrop = true;
				Timer activateTimer = new Timer();
				activateTimer.Interval = SystemInformation.DoubleClickTime;
				activateTimer.Tick += new EventHandler(ActivateTimer_Tick);
				myDragActivateTabIndex = -1;
				myDragActivateTimer = activateTimer;
	
				base.ResumeLayout(false);
				parentControl.ResumeLayout(false);
			}