Ejemplo n.º 1
0
        private static bool MouseWithinViewport(int x, int y)
        {
            var size = Game.FocusedCamera.ViewportSize;
            var pos  = CurrentControl.PointToClient(new Point(x, y));

            return((pos.X > 0) && (pos.X < size.x) && (pos.Y > 0) && (pos.Y < size.y));
        }
Ejemplo n.º 2
0
        protected override void HandleInput()
        {
            if (CurrentControl != null)
            {
                if (InputManager.IsMouseButtonStroked(MouseButtons.Left))
                {
                    CurrentControl.CheckClick();
                }
                else
                if (CurrentControl.ID == "Layer" + mapCreator.CurrentTileLayer)
                {
                    if (InputManager.IsMouseButtonStroked(MouseButtons.Right))
                    {
                        mapCreator.ChangeSourceIndex(-1);
                    }

                    if (InputManager.IsMouseButtonPressed(MouseButtons.Left))
                    {
                        CurrentControl.CheckClick();
                    }
                }
            }

            if (InputManager.IsKeyStroked(Keys.H))
            {
                chkGrid.Toggle(true);
            }

            if (InputManager.IsKeyStroked(Keys.L))
            {
                chkLayers.Toggle(true);
            }

            base.HandleInput();
        }
Ejemplo n.º 3
0
        public virtual void StyleExistsOnContainer()
        {
            ListBoxItem item = null;

            item = new ListBoxItem();
            CurrentControl.PrepareContainerForItemOverride_(item, new object());
            Assert.IsUnset(item, ListBoxItem.StyleProperty, "#1");

            CurrentControl.ItemContainerStyle = null;
            item = new ListBoxItem();
            CurrentControl.PrepareContainerForItemOverride_(item, new object());
            Assert.IsUnset(item, ListBoxItem.StyleProperty, "#2");

            CurrentControl.ItemContainerStyle = new Style(typeof(ListBoxItem));
            item = new ListBoxItem();
            CurrentControl.PrepareContainerForItemOverride_(item, new object());
            Assert.AreEqual(CurrentControl.ItemContainerStyle, item.ReadLocalValue(ListBoxItem.StyleProperty), "#3");

            Style containerStyle = new Style(typeof(ListBoxItem));

            item = new ListBoxItem {
                Style = containerStyle
            };
            CurrentControl.PrepareContainerForItemOverride_(item, new object());
            Assert.AreEqual(containerStyle, item.ReadLocalValue(ListBoxItem.StyleProperty), "#4");
        }
Ejemplo n.º 4
0
        public virtual void GetContainerForItemOverride3()
        {
            // Subclass must do the testing of the created item
            // when there's a style
            Selector s = (Selector)CurrentControl;

            s.SetValue(s is ComboBox ? ComboBox.ItemContainerStyleProperty : ListBox.ItemContainerStyleProperty, new Style(typeof(ListBoxItem)));
            CurrentControl.GetContainerForItemOverride_();
        }
Ejemplo n.º 5
0
        private async void ExecuteSelection(object sender, SelectionArgs e)
        {
            var session = _driver.AsyncSession();

            try
            {
                var worksheet  = ((Worksheet)Application.ActiveSheet);
                var inputrange = e.SelectionRange;

                if (_connected == false)
                {
                    var control = _customTaskPane.Control as ExecuteQuery;
                    ConnectDatabase(this, new ConnectDatabaseArgs {
                        ConnectionString = control.ConnectionString()
                    });
                }

                /*
                 * using (session)
                 * {
                 *  for (int r = 1; r <= inputrange.Rows.Count; r++)
                 *  {
                 *
                 *      string cypher = "";
                 *
                 *      foreach (Range col in inputrange.Rows[r].Columns)
                 *      {
                 *          try
                 *          {
                 *              cypher += col.Cells[1, 1].Value2.ToString();
                 *          }
                 *          catch
                 *          {
                 *
                 *          }
                 *      }
                 *      var result = session.Run(cypher);
                 *
                 *      if (r == inputrange.Rows.Count)
                 *      {
                 *          CurrentControl.SetMessage(result.Summary.Statement.Text);
                 *      }
                 *
                 *  }
                 * }*/
            }
            catch (Neo4jException ex)
            {
                CurrentControl.SetMessage(ex.Message);
            }
            finally
            {
                await session.CloseAsync();
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     Changes the current control
        /// </summary>
        /// <remarks>This function can only be called from within the class that inherits this one</remarks>
        private void ChangeCurrentControl()
        {
            if (Dispatcher.Thread != Thread.CurrentThread)
            {
                Dispatcher.BeginInvoke(new Action(ChangeCurrentControl));

                return;
            }

            CurrentControl?.RaiseEvent(new RoutedEventArgs(UnloadedEvent, CurrentControl));

            Content = Activator.CreateInstance(Controls[CurrentControlIndex], this);
        }
Ejemplo n.º 7
0
        public void ItemsSource_ResetEvent()
        {
            var list = new ManualINCC();

            CurrentControl.ItemsSource = list;
            CreateAsyncTest((FrameworkElement)CurrentControl,
                            () => CurrentControl.ApplyTemplate(),
                            () => {
                list.AddRange(new [] { new object(), new object() });
                list.RaiseINCC(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                Assert.AreEqual(2, CurrentControl.Items.Count, "#1");
            }
                            );
        }
Ejemplo n.º 8
0
        public virtual void PrepareContainerForItemOverrideSelector2()
        {
            Style              style = new Style(typeof(ListBoxItem));
            Selector           box   = (Selector)CurrentControl;
            DependencyProperty prop  = box is ComboBox ? ComboBox.ItemContainerStyleProperty : ListBox.ItemContainerStyleProperty;

            box.SetValue(prop, style);

            ComboBoxItem item = new ComboBoxItem();

            Assert.IsNull(item.Style, "#1");

            CurrentControl.PrepareContainerForItemOverride_(item, null);
            Assert.AreSame(item.Style, box.GetValue(prop), "#4");
        }
Ejemplo n.º 9
0
        private void SetLocks()
        {
            PrimesBigInteger value = iscNumber.GetValue();

            if (value != null)
            {
                if (CurrentControl.IsRunning())
                {
                    iscNumber.LockControls();
                }
                else
                {
                    iscNumber.UnLockControls();
                }
            }
        }
Ejemplo n.º 10
0
        private void OpenTexturesWindowButton_Click(object sender, EventArgs e)
        {
            if (CurrentControl != null)
            {
                CurrentControl.Hide();
                MainWindowHostPanel.Controls.Remove(CurrentControl);
            }

            CurrentControl = new TextureWindow
            {
                Anchor      = AnchorAll,
                MinimumSize = new Size(1100, 660)
            };

            MainWindowHostPanel.Controls.Add(CurrentControl);
        }
Ejemplo n.º 11
0
        private async Task <List <IRecord> > ExecuteCypherQuery(string queryString)
        {
            var            session = _driver.AsyncSession();
            List <IRecord> records = new List <IRecord>();

            try
            {
                if (_connected == false)
                {
                    var control = _customTaskPane.Control as ExecuteQuery;
                    ConnectDatabase(this, new ConnectDatabaseArgs {
                        ConnectionString = control.ConnectionString()
                    });
                }

                var worksheet = ((Worksheet)Application.ActiveSheet);

                try
                {
                    IResultCursor cursor = await session.RunAsync(queryString);

                    records = await cursor.ToListAsync();

                    var summary = await cursor.ConsumeAsync();

                    string summaryText = summary.ToString();

                    CurrentControl.SetMessage("Execution Summary :" + "\n\n" + summaryText);
                    return(records);
                }
                finally
                {
                    await session.CloseAsync();
                }
            }
            catch (Neo4jException ex)
            {
                CurrentControl.SetMessage(ex.Message);
            }
            finally
            {
                await session.CloseAsync();
            }

            return(records);
        }
Ejemplo n.º 12
0
        private void ExecuteSelection(object sender, SelectionArgs e)
        {
            try
            {
                var worksheet  = ((Worksheet)Application.ActiveSheet);
                var inputrange = e.SelectionRange;

                if (_connected == false)
                {
                    var control = _customTaskPane.Control as ExecuteQuery;
                    ConnectDatabase(this, new ConnectDatabaseArgs {
                        ConnectionString = control.ConnectionString()
                    });
                }

                using (var session = _driver.Session())
                {
                    for (int r = 1; r <= inputrange.Rows.Count; r++)
                    {
                        string cypher = "";

                        foreach (Range col in inputrange.Rows[r].Columns)
                        {
                            try
                            {
                                cypher += col.Cells[1, 1].Value2.ToString();
                            }
                            catch
                            {
                            }
                        }
                        var result = session.Run(cypher);

                        if (r == inputrange.Rows.Count)
                        {
                            CurrentControl.SetMessage(result.Summary.Statement.Text);
                        }
                    }
                }
            }
            catch (Neo4jException ex)
            {
                CurrentControl.SetMessage(ex.Message);
            }
        }
Ejemplo n.º 13
0
        public virtual void ChangeContainerStyle()
        {
            Selector selector = (Selector)CurrentControl;
            Style    first    = new Style(typeof(ListBoxItem));

            ListBoxItem item = (ListBoxItem)CreateContainer();

            item.Content = "A";

            Enqueue(() => TestPanel.Children.Add(selector));
            Enqueue(() => CurrentControl.ApplyTemplate());
            Enqueue(() => {
                if (CurrentControl is ComboBox)
                {
                    ((ComboBox)CurrentControl).IsDropDownOpen = true;
                }
            });
            Enqueue(() => CurrentControl.Items.Add(item));
            Enqueue(() => CurrentControl.ItemContainerStyle = first);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Sends the selected character to the answer control (PEanswer) and sets the focus back on CharacterForm.
        /// </summary>
        /// <param name="sender">Button object that raised the event.</param>
        /// <param name="e">System.EventArgs that contains the event data.</param>
        /// <remarks>Documented by Dev03, 2007-07-20</remarks>
        private void SomeButtons_Click(object sender, System.EventArgs e)
        {
            // Add symbol to currently focused control
            string Symbol = (string)(sender as Button).Tag;

            if (CurrentControl != null)
            {
                if (CurrentControl is MLifter.Components.MLifterTextBox)
                {
                    (CurrentControl as MLifter.Components.MLifterTextBox).SendChar(Symbol[0]);
                }
                else if (CurrentControl is TextBox)
                {
                    TextBox textbox        = CurrentControl as TextBox;
                    int     selectionstart = textbox.SelectionStart;
                    string  newtext        = string.Empty;
                    newtext               += textbox.Text.Substring(0, textbox.SelectionStart);
                    newtext               += Symbol;
                    newtext               += textbox.Text.Substring(textbox.SelectionStart + textbox.SelectionLength, textbox.Text.Length - textbox.SelectionStart - textbox.SelectionLength);
                    textbox.Text           = newtext;
                    textbox.SelectionStart = selectionstart + Symbol.Length;
                }
                else if (CurrentControl is ListView && CurrentControl.Parent.Parent is CardEdit)
                {
                    (CurrentControl.Parent.Parent as CardEdit).SendListViewChar(Symbol, (ListView)CurrentControl);
                }

                this.TopMost = true;

                // Set focus back
                if (CurrentControl.Visible)
                {
                    CurrentControl.Focus();
                }
            }
        }
Ejemplo n.º 15
0
 private void SyncAllNodes(object sender, EventArgs e)
 {
     ExecuteLoadAllNodes();
     CurrentControl.SetMessage("SYNC");
 }
Ejemplo n.º 16
0
        void BtnClicked(string controlID)
        {
            if (controlID.Contains("Recent_"))
            {
                string filepath = ((TextButton)CurrentControl).Text;
                bool   found    = false;

                if (SerializationHelper.FileExists(filepath))
                {
                    recent.Add(filepath);

                    string text = filepath;

                    string[] split = text.Split(new char[]
                    {
                        '\\', '/'
                    });

                    int len = split[split.Length - 1].Length;
                    len++;

                    text = text.Remove(text.Length - len, len);

                    text += InterOperations.LibraryFilepathExtention;

                    Crosswalk.Message message = new Crosswalk.Message()
                    {
                        Messages = new string[] { text }
                    };

                    SerializationHelper.Serialize <EEDK.Crosswalk.Message>(message, "Temp.temp", "");

                    LoadProject(filepath);

                    InterOperations.ProjectName = SerializationHelper.GetFolderName(
                        filepath.Remove(filepath.Length -
                                        InterOperations.ProjectFileExtention.Length,
                                        InterOperations.ProjectFileExtention.Length));

                    len = ".EPROJ".Length + InterOperations.ProjectName.Length;
                    InterOperations.RootFilepath = filepath.Remove(filepath.Length - len, len);

                    InterOperations.Project.ProjectRootFilepath = InterOperations.RootFilepath;
                    InterOperations.Project.ProjectName         = InterOperations.ProjectName;

                    found = true;
                }
                else
                {
                    recent.Remove(filepath);
                    CurrentControl.Destroy();
                }

                SaveRecent();

                if (found)
                {
                    StartLibraryReader();
                }
            }
            else
            {
                switch (controlID)
                {
                case "Load Level":
                {
                    Common.ShowMouse(true);

                    if (openDia.ShowDialog() == DialogResult.OK)
                    {
                        string filepath = openDia.FileName;

                        recent.Add(filepath);

                        Crosswalk.Message message = new Crosswalk.Message()
                        {
                            Messages = new string[] { (filepath.Remove(filepath.Length -
                                                                       (openDia.SafeFileName.Length + 1), openDia.SafeFileName.Length + 1)) +
                                                      InterOperations.LibraryFilepathExtention }
                        };

                        SerializationHelper.Serialize <Crosswalk.Message>(message, "Temp.temp", "");

                        LoadProject(filepath);

                        InterOperations.ProjectName = SerializationHelper.GetFolderName(
                            filepath.Remove(filepath.Length -
                                            InterOperations.ProjectFileExtention.Length,
                                            InterOperations.ProjectFileExtention.Length));

                        int len = ".EPROJ".Length + InterOperations.ProjectName.Length;
                        InterOperations.RootFilepath = filepath.Remove(filepath.Length - len, len);

                        InterOperations.Project.ProjectRootFilepath = InterOperations.RootFilepath;
                        InterOperations.Project.ProjectName         = InterOperations.ProjectName;

                        StartLibraryReader();
                    }

                    Common.ShowMouse(false);

                    SaveRecent();
                }
                break;

                case "New Level":
                {
                    Common.ShowMouse(true);

                    if (folderDia.ShowDialog() == DialogResult.OK)
                    {
                        string root = folderDia.SelectedPath;

                        InterOperations.RootFilepath = root + "\\";
                        InterOperations.Project      = new Crosswalk.ProjectFile();
                        InterOperations.ProjectName  = SerializationHelper.GetFolderName(root);
                        recent.Add(root + "\\" + InterOperations.ProjectName + InterOperations.ProjectFileExtention);

                        InterOperations.Project.ProjectRootFilepath = InterOperations.RootFilepath;
                        InterOperations.Project.ProjectName         = InterOperations.ProjectName;
                        InterOperations.Project.Framework           = new FrameworkCreation()
                        {
                            AssemblyRefferences = new string[]
                            {
                                "Eon",
                                "Eon.Rendering2D",
                                "Eon.Rendering3D"
                            },
                            DefaultLanguage         = "English",
                            DefaultScreenResolution = 0,
                            DefaultScreenSize       = 0,
                            DefaultTextureQuality   = 2,
                            FullScreen       = true,
                            TargetFramerate  = 166,
                            EngineComponents = new ParameterCollection[]
                            {
                                new ParameterCollection
                                {
                                    ObjectType = "Eon.Rendering3D.Framework.Framework"
                                },
                                new ParameterCollection
                                {
                                    ObjectType = "Eon.Rendering2D.Framework.Framework"
                                }
                            }
                        };

                        string lib = root + InterOperations.LibraryFilepathExtention;
                        SerializationHelper.CopyFiles(Environment.CurrentDirectory, lib, ".dll", "Eon.", true);

                        string content = root + EEDK.Crosswalk.InterOperations.ContentFilepathExtention + "\\Eon";
                        string eonRoot = Environment.CurrentDirectory + "\\Content\\Eon";
                        SerializationHelper.CopyFiles(eonRoot, content, ".xnb", true);

                        EEDK.Crosswalk.Message message = new Crosswalk.Message()
                        {
                            Messages = new string[] { lib }
                        };

                        SerializationHelper.Serialize <EEDK.Crosswalk.Message>(message, "Temp.temp", "");

                        StartLibraryReader();
                    }

                    Common.ShowMouse(false);

                    SaveRecent();
                }
                break;

                default:
                    Common.ExitGame();
                    break;
                }
            }
        }
Ejemplo n.º 17
0
        private async void UpdateActiveWorksheet(object sender, SelectionArgs e)
        {
            var control = _customTaskPane.Control as ExecuteQuery;

            if (_connected == false)
            {
                ConnectDatabase(this, new ConnectDatabaseArgs {
                    ConnectionString = control.ConnectionString()
                });
            }
            var session = _driver.AsyncSession();

            try
            {
                var worksheet  = ((Worksheet)Application.ActiveSheet);
                var inputrange = e.SelectionRange;
                inputrange = worksheet.UsedRange;
                int indexOfIdentifier = 0;

                control.progress.Report(0);

                if (inputrange.Columns.Count <= 1)
                {
                    CurrentControl.SetMessage("Select more than 1 column");
                }


                string[] properties = new string[inputrange.Columns.Count];
                for (int i = 0; i < inputrange.Columns.Count; i++)
                {
                    int excelIndex = i + 1;
                    try
                    {
                        string colName = Convert.ToString(inputrange.Cells[1, excelIndex].Value2);
                        properties[i] = colName;
                        string s = colName.ToLowerInvariant();
                        if (s == "uuid")
                        {
                            indexOfIdentifier = i;
                        }
                    }
                    catch
                    {
                        properties[i - 2] = "property" + (i - 1).ToString();
                    }
                }


                for (int r = 2; r <= inputrange.Rows.Count; r++)
                {
                    control.progress.Report(r / inputrange.Rows.Count * 100);
                    var row   = inputrange.Rows[r];
                    var label = "";
                    try
                    {
                        label = row.Cells[1, 1].Value2.ToString();
                        label = worksheet.Name;
                    }
                    catch
                    {
                        label = "NewExcelNode";
                    }

                    string cypher = "MERGE (a: " + label + " { ";

                    {
                        cypher += GetIdentifierPropertyValue(row, properties, indexOfIdentifier);
                    }
                    cypher  = cypher.TrimEnd(',');
                    cypher += "})";

                    // check if worksheet have 1 property column + 1 data column
                    if (row.columns.count > 1)
                    {
                        cypher += " SET a += { ";
                        for (int i = 0; i < row.Columns.Count; i++)
                        {
                            int excelIndex = i + 1;
                            // Skip first record as it is used in Merge identifier.
                            if (i == indexOfIdentifier)
                            {
                                continue;
                            }
                            string secondRecordValue = Convert.ToString(row.Cells[1, excelIndex].Value2);

                            if (properties[i] != null && secondRecordValue != null)
                            {
                                if (properties[i].Length > 0 && secondRecordValue.Length > 0)
                                {
                                    cypher += "`" + properties[i] + "`" + ": \"" + secondRecordValue + "\",";
                                }
                            }
                        }
                        cypher  = cypher.TrimEnd(',');
                        cypher += "}";
                    }



                    try
                    {
                        IResultCursor cursor = await session.RunAsync(cypher);

                        var records = await cursor.ToListAsync();

                        var summary = await cursor.ConsumeAsync();

                        string message = summary.ToString();
                        if (r == inputrange.Rows.Count)
                        {
                            CurrentControl.SetMessage(message);
                        }
                    }
                    catch (Neo4jException ee)
                    {
                        CurrentControl.SetMessage(ee.Message);
                    }
                }
                await session.CloseAsync();
            }
            catch (Neo4jException ex)
            {
                CurrentControl.SetMessage(ex.Message);
            }
        }
Ejemplo n.º 18
0
        private void CreateNodes(object sender, SelectionArgs e)
        {
            try
            {
                var worksheet  = ((Worksheet)Application.ActiveSheet);
                var inputrange = e.SelectionRange;

                if (_connected == false)
                {
                    var control = _customTaskPane.Control as ExecuteQuery;
                    ConnectDatabase(this, new ConnectDatabaseArgs {
                        ConnectionString = control.ConnectionString()
                    });
                }

                using (var session = _driver.Session())
                {
                    if (inputrange.Columns.Count <= 1)
                    {
                        CurrentControl.SetMessage("Select more than 1 column");
                    }

                    string[] properties = new string[inputrange.Columns.Count];
                    for (int i = 2; i <= inputrange.Columns.Count; i++)
                    {
                        try
                        {
                            properties[i - 2] = inputrange.Cells[1, i].Value2.ToString();
                        }
                        catch
                        {
                            properties[i - 2] = "property" + (i - 1).ToString();
                        }
                    }

                    for (int r = 2; r <= inputrange.Rows.Count; r++)
                    {
                        var row   = inputrange.Rows[r];
                        var label = "";
                        try
                        {
                            label = row.Cells[1, 1].Value2.ToString();
                        }
                        catch
                        {
                            label = "NewExcelNode";
                        }

                        string cypher = "MERGE (a: " + label + " { ";
                        for (int i = 2; i <= row.Columns.Count; i++)
                        {
                            cypher += properties[i - 2].ToString() + ": \"" + row.Cells[1, i].Value2.ToString() + "\",";
                        }
                        cypher  = cypher.TrimEnd(',');
                        cypher += "})";

                        var result = session.Run(cypher);
                        if (r == inputrange.Rows.Count)
                        {
                            CurrentControl.SetMessage(result.Summary.Statement.Text);
                        }
                    }
                }
            }
            catch (Neo4jException ex)
            {
                CurrentControl.SetMessage(ex.Message);
            }
        }
Ejemplo n.º 19
0
 private void iscNumber_Execute(PrimesBigInteger value)
 {
     CurrentControl.Execute(value);
 }
Ejemplo n.º 20
0
        private void BtnDienKhuyet_Click(object sender, EventArgs e)
        {
            txtCtrlNoiDungCauHoi.Focus();
            //Them vao cau tra loi
            if (txtCtrlNoiDungCauHoi.SelectionLength == 0)
            {
                UICommon.ShowMsgWarningString("Bạn chưa chọn nội dung cần điền khuyết");
                return;
            }
            var textStart = txtCtrlNoiDungCauHoi.SelectionStart;

            //Kiem tra vi tri dien khuyet
            if (_mathCollection != null)
            {
                for (int i = 0; i < _mathCollection.Count; i++)
                {
                    var viTriNext = _mathCollection[i].Index + _mathCollection[i].Length;
                    if (textStart >= _mathCollection[i].Index && textStart <= viTriNext)
                    {
                        UICommon.ShowMsgWarningString("Vị trí điền khuyết không hợp lệ!");
                        if (txtCtrlNoiDungCauHoi.SelectionLength == 0)
                        {
                            txtCtrlNoiDungCauHoi.Undo();
                        }
                        return;
                    }
                }
            }

            var tmp = txtCtrlNoiDungCauHoi.SelectedRtf;

            //Buoc 2: Add cau tra loi dau tien cho cau hoi hien tai => vi trí diền khuyết
            if (txtCtrlNoiDungCauHoi.SelectionLength != 0)
            {
                //Gan du lieu toan cuc và cboCauHoi
                CauHoiCurent = new EX_CauHoi {
                    IDEx = ListCauHoi.Count + 1, DoKho = IdMucDoNhanThuc
                };
                //Buoc 1
                ListCauHoi.Add(CauHoiCurent);
                CauHoiCurent.ListCauTraLoi.Add(new EX_CauTraLoi {
                    IdEx = 1, NoiDung = txtCtrlNoiDungCauHoi.SelectedRtf, IndexEx = textStart
                });

                var textStt = string.Format("({0})_____", ListCauHoi.Count);
PasteClipboard:
                {
                    try
                    {
                        Clipboard.SetText(textStt);
                    }
                    catch (Exception)
                    {
                        goto PasteClipboard;
                    }
                }
                txtCtrlNoiDungCauHoi.Paste();
            }
            else
            {
                UICommon.ShowMsgWarningString("Nội dung chọn không hợp lệ");
                if (txtCtrlNoiDungCauHoi.SelectionLength == 0)
                {
                    txtCtrlNoiDungCauHoi.Undo();
                }
                return;
            }

            //Buoc 3: do du lieu len cbo
            if (ListCauHoi.Count > 0)
            {
                SetDataToCboCauHoi();
            }
            //Buoc 4 => changCategoryID
            _isDienKhuyet        = true;
            cboCauHoi.CategoryID = ListCauHoi.Count;
            IdCauHoiCurent       = (int)cboCauHoi.CategoryID;

            //Ve lai cau hoi => phan ben trai
            ClearAllCauTraLoi();
            ClearAllCauTraLoiGayNhieu();
            ThemCauTraLoi();

            CurrentControl.Focus();
            CurrentControl.Rtf      = tmp;
            CurrentControl.ReadOnly = true;

            // Nhận dạng lại vị trí
            _mathCollection = _parsing.ParseDienKhuyet2(txtCtrlNoiDungCauHoi.Text);
        }
Ejemplo n.º 21
0
 private void iscNumber_Cancel()
 {
     CurrentControl.CancelExecute();
     SetLocks();
 }
Ejemplo n.º 22
0
 public override void IsItemItsOwnContainerTest()
 {
     base.IsItemItsOwnContainerTest();
     Assert.IsFalse(CurrentControl.IsItemItsOwnContainerOverride_(CurrentControl));
 }
Ejemplo n.º 23
0
 private void UpdateAllNodes(object sender, SelectionArgs e)
 {
     CurrentControl.SetMessage("PUSH");
     UpdateActiveWorksheet(sender, e);
 }
Ejemplo n.º 24
0
 private void LoadAllNodes(object sender, SelectionArgs e)
 {
     //ExecuteLoadAllNodes(sender, e);
     ExecuteLoadActiveWorksheet(sender, e);
     CurrentControl.SetMessage("PULL");
 }
Ejemplo n.º 25
0
 public override void IsItemItsOwnContainerTest()
 {
     base.IsItemItsOwnContainerTest();
     Assert.IsTrue(CurrentControl.IsItemItsOwnContainerOverride_(new ComboBoxItem()));
     Assert.IsTrue(CurrentControl.IsItemItsOwnContainerOverride_(new ListBoxItem()));
 }
Ejemplo n.º 26
0
        private async void CreateNodes(object sender, SelectionArgs e)
        {
            var control = _customTaskPane.Control as ExecuteQuery;

            if (_connected == false)
            {
                ConnectDatabase(this, new ConnectDatabaseArgs {
                    ConnectionString = control.ConnectionString()
                });
            }
            var session = _driver.AsyncSession();

            try
            {
                var worksheet  = ((Worksheet)Application.ActiveSheet);
                var inputrange = e.SelectionRange;



                control.progress.Report(0);

                if (inputrange.Columns.Count <= 1)
                {
                    CurrentControl.SetMessage("Select more than 1 column");
                }

                string[] properties = new string[inputrange.Columns.Count];
                for (int i = 2; i <= inputrange.Columns.Count; i++)
                {
                    try
                    {
                        properties[i - 2] = Convert.ToString(inputrange.Cells[1, i].Value2);
                    }
                    catch
                    {
                        properties[i - 2] = "property" + (i - 1).ToString();
                    }
                }



                for (int r = 2; r <= inputrange.Rows.Count; r++)
                {
                    control.progress.Report(r / inputrange.Rows.Count * 100);
                    var row   = inputrange.Rows[r];
                    var label = "";
                    try
                    {
                        label = row.Cells[1, 1].Value2.ToString();
                    }
                    catch
                    {
                        label = "NewExcelNode";
                    }

                    string cypher = "MERGE (a: " + label + " { ";
                    int    i      = 2;
                    {
                        string propval = Convert.ToString(row.Cells[1, i].Value2);

                        if (properties[i - 2].Length > 0 && propval.Length > 0)
                        {
                            cypher += "`" + properties[i - 2] + "`" + ": \"" + propval + "\",";
                        }
                    }
                    cypher  = cypher.TrimEnd(',');
                    cypher += "})";



                    if (row.columns.count > 2)
                    {
                        cypher += " SET a += { ";
                        for (i = 3; i <= row.Columns.Count; i++)
                        {
                            string propval = Convert.ToString(row.Cells[1, i].Value2);

                            if (properties[i - 2] != null && propval != null)
                            {
                                if (properties[i - 2].Length > 0 && propval.Length > 0)
                                {
                                    cypher += "`" + properties[i - 2] + "`" + ": \"" + propval + "\",";
                                }
                            }
                        }
                        cypher  = cypher.TrimEnd(',');
                        cypher += "}";
                    }



                    try
                    {
                        IResultCursor cursor = await session.RunAsync(cypher);

                        var records = await cursor.ToListAsync();

                        var summary = await cursor.ConsumeAsync();

                        string message = summary.ToString();
                        if (r == inputrange.Rows.Count)
                        {
                            CurrentControl.SetMessage(message);
                        }
                    }
                    catch (Neo4jException ee)
                    {
                        CurrentControl.SetMessage(ee.Message);
                    }
                }
                await session.CloseAsync();
            }
            catch (Neo4jException ex)
            {
                CurrentControl.SetMessage(ex.Message);
            }
        }
Ejemplo n.º 27
0
 public void Refresh() => CurrentControl.Refresh();
Ejemplo n.º 28
0
        private Dictionary <string, bool> IsValid()
        {
            if (!(FindForm() is FBase))
            {
                return(new Dictionary <string, bool>());
            }
            if (!(GetSForm().StateForm == StateForm.Inserting || GetSForm().StateForm == StateForm.Editing))
            {
                return(new Dictionary <string, bool>());
            }
            try
            {
                if (Name == string.Empty)
                {
                    return(new Dictionary <string, bool>());
                }
                Validations = new Dictionary <string, bool>();

                if (GetSForm() == null)
                {
                    RemoveErrorProvider();
                    return(new Dictionary <string, bool>());
                }
                if (PropertyControl == null)
                {
                    return(new Dictionary <string, bool>());
                }
                var validationAttributes = GetAttribute();
                var reflection           = new SReflection();
                foreach (var attribute in validationAttributes)
                {
                    try
                    {
                        var validationAttribute = attribute as ValidationAttribute;
                        if (validationAttribute == null)
                        {
                            continue;
                        }
                        bool isValid;

                        var operatorValue = GetAttribute <OperationValue>(PropertyControl);
                        if (operatorValue != null)
                        {
                            decimal result     = 0;
                            var     component1 =
                                GetSForm()
                                .GetListControls()
                                .FirstOrDefault(c => c.Name == operatorValue.PropertyOperationName);
                            var componentTotal =
                                GetSForm()
                                .GetListControls()
                                .FirstOrDefault(c => c.Name == operatorValue.PropertyResultName);
                            if (component1 != null)
                            {
                                if (componentTotal != null)
                                {
                                    switch (operatorValue.TypeOperation)
                                    {
                                    case TypeOperation.Division:
                                        if ((decimal)ValueControl != 0)
                                        {
                                            result = (decimal)component1.ValueControl / (decimal)ValueControl;
                                        }
                                        break;

                                    case TypeOperation.Multiplication:
                                        result = (decimal)ValueControl * (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.Sum:
                                        result = (decimal)ValueControl + (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.Subtraction:
                                        result = (decimal)component1.ValueControl - (decimal)ValueControl;
                                        break;

                                    case TypeOperation.SubtractionInversion:
                                        result = (decimal)ValueControl - (decimal)component1.ValueControl;
                                        break;

                                    case TypeOperation.SubtractionPorcent:
                                        result = (decimal)component1.ValueControl - (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    case TypeOperation.AditionalPorcent:
                                        result = (decimal)component1.ValueControl + (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    case TypeOperation.PorcentValue:
                                        result = (((decimal)component1.ValueControl / 100) * (decimal)ValueControl);
                                        break;

                                    default:
                                        result = 0;
                                        break;
                                    }
                                }
                            }
                            componentTotal.Disable      = false;
                            componentTotal.ValueControl = result;
                        }

                        if (validationAttribute is LockedTrueValue)
                        {
                            var lockedTrueValue = validationAttribute as LockedTrueValue;
                            var valid           = false;
                            if (lockedTrueValue.UniqueValue)
                            {
                                valid = lockedTrueValue.Value[0].ToString() != ValueControl.ToString();
                            }
                            for (var i = 0; i < lockedTrueValue.PropertyName.Count(); i++)
                            {
                                if (!lockedTrueValue.UniqueValue)
                                {
                                    valid = lockedTrueValue.Value[i]?.ToString() != PropertyControl?.GetValue(GetSForm()?.CurrentControl)?.ToString();
                                }

                                var component = GetSForm().GetListControls().FirstOrDefault(c => c.Name == lockedTrueValue.PropertyName[i]);
                                component.Disable = valid;
                                if (!valid)
                                {
                                    component.Clear();
                                }
                            }
                        }

                        if (validationAttribute is CompareAttribute)
                        {
                            var otherName     = validationAttribute.GetType().GetProperty("OtherProperty").GetValue(validationAttribute).ToString();
                            var otherProperty = CurrentControl.GetType().GetProperty(otherName);
                            var otherValue    = otherProperty.GetValue(CurrentControl);
                            isValid = otherValue?.ToString() == ValueControl.ToString();
                        }
                        else
                        {
                            if (this is SComboBox)
                            {
                                isValid = !ValueControl.ToString().Equals("0");
                            }
                            else
                            {
                                isValid = validationAttribute.IsValid(ValueControl);
                            }
                        }
                        var key = validationAttribute.FormatErrorMessage(DisplayName(PropertyControl));
                        if (!isValid && !Validations.ContainsKey(key))
                        {
                            Validations.Add(key, false);
                        }

                        var compoundIndex = GetSForm().GetAttribute <CompoundIndex>();
                        var unique        = attribute as Unique;

                        if ((compoundIndex != null && compoundIndex.Properties.Contains(Name)) || unique != null)
                        {
                            var typeValue = ValueControl as string;
                            if (!(typeValue != null && ReferenceEquals(ValueControl, string.Empty)))
                            {
                                // Pego o tipo do contexto.
                                var typeDataSource = GetSForm().InvokeMethod.TypeModel;

                                // Para garantia de Lista anonima (generica), pesquisa pela propriedade Id,
                                // chave primária do objeto.
                                var property = PropertyControl;

                                // Pego o valor da propriedade do objeto atual.
                                var value = ValueControl;

                                // se o tipo do objeto já foi informado para mesmo contexto, não é passado mais.
                                var parameterType = Expression.Parameter(typeDataSource);

                                // passa o tipo da propriedade
                                var prop = Expression.Property(parameterType, property);
                                // converte o tipo do dado, para garantir a identidade do mesmo.
                                var convertedValue = reflection.ChangeType(value, property.PropertyType);
                                // cria expressao do valor que será passada na expressão.
                                var soap = Expression.Constant(convertedValue);
                                // relaciona a propriedade com o dado. Exemplo: param0 => param0 == 1
                                var equal = Expression.Equal(prop, soap);

                                Expression expressionCompound = null;
                                // Se acaso for index composto adiciona mais uma expressão
                                if (compoundIndex != null && compoundIndex.Properties.Contains(Name))
                                {
                                    // Pesquiso  as outras propriedades que fazem parte da composição.
                                    var properties = compoundIndex.Properties.Where(c => c != Name);

                                    expressionCompound = (from index in properties select typeDataSource.GetProperty(index) into propertyCompoundId let propCompoundId = Expression.Property(parameterType, propertyCompoundId) let convertedValueCompoundId = reflection.ChangeType(propertyCompoundId.GetValue(GetSForm().CurrentControl), propertyCompoundId.PropertyType) let soapCompoundId = Expression.Constant(convertedValueCompoundId) select Expression.Equal(propCompoundId, soapCompoundId)).Aggregate(expressionCompound, (current, equalCompoundId) => current == null ? equalCompoundId : Expression.And(equalCompoundId, current));
                                }

                                if (expressionCompound != null)
                                {
                                    equal = Expression.And(equal, expressionCompound);
                                }

                                var propertyId = typeDataSource.GetProperty("Id");
                                // passa o tipo da propriedade
                                var propId = Expression.Property(parameterType, propertyId);
                                // converte o tipo do dado, para garantir a identidade do mesmo.
                                var convertedValueId = Convert.ChangeType(propertyId.GetValue(GetSForm().CurrentControl), propertyId.PropertyType);
                                // cria expressao do valor que será passada na expressão.
                                var soapId = Expression.Constant(convertedValueId);
                                // relaciona a propriedade com o dado. Exemplo: param0 => param0 == 1
                                var equalId = Expression.NotEqual(propId, soapId);

                                var yourExpression = Expression.And(equal, equalId);

                                var delegateType = typeof(Func <,>).MakeGenericType(typeDataSource, typeof(bool));
                                var expression   = Expression.Lambda(delegateType, yourExpression, true, parameterType);
                                var objetoApp    = GetSForm().InvokeMethod;
                                var method       = objetoApp.Methods.FirstOrDefault(c => c.Key == TypeExecute.Search).Value;
                                if (string.IsNullOrEmpty(method))
                                {
                                    MessageBox.Show("Método Search não configurado\nController: " + objetoApp.TypeController.Name,
                                                    "ESR Softwares", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                }
                                var result = reflection.GetListContext(objetoApp.TypeController, method, expression);

                                var components = GetSForm().GetListControls().Where(c =>
                                {
                                    if (compoundIndex == null)
                                    {
                                        return(false);
                                    }
                                    foreach (var s in compoundIndex.Properties)
                                    {
                                        if (Equals(s, c.Name))
                                        {
                                            break;
                                        }
                                    }
                                    return(false);
                                });

                                if (result.Any())
                                {
                                    if (compoundIndex != null && compoundIndex.Properties.Contains(Name))
                                    {
                                        var enumerable      = components as IList <IComponent> ?? components.ToList();
                                        var componentValues = enumerable.Aggregate("", (current, component) => current + component.Caption + " = " + component.ValueControl + " ");
                                        foreach (var component in enumerable)
                                        {
                                            component.SetError("Já existem dados com " + componentValues);
                                            component.ComponentBackColor = Color.FromArgb(255, 255, 173, 178);
                                        }
                                        Validations.Add("Já existem dados com " + (componentValues == "" ? " este registro" : componentValues), false);
                                    }
                                    else
                                    {
                                        Validations.Add("Este " + GetTextLabel() + " já existe, considere em informar outro", false);
                                    }
                                }
                                else
                                {
                                    foreach (var component in components)
                                    {
                                        if (!component.Validations.Values.Contains(false))
                                        {
                                            component.RemoveErrorProvider();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    SComponent.BackColor = Validations.Values.Contains(false) ? Color.FromArgb(255, 255, 173, 178) : Color.White;
                }
                return(Validations);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
        }
Ejemplo n.º 29
0
 // Update is called once per frame
 void Update()
 {
     CurrentControl.Move();
 }