Example #1
0
        private void CcSymbolsAddClicked(object sender, EventArgs e)
        {
            ISymbol s    = null;
            string  type = cmbSymbolType.SelectedItem.ToString();

            switch (type)
            {
            case "Simple":
                s = new SimpleSymbol();
                break;

            case "Character":
                s = new CharacterSymbol();
                break;

            case "Picture":
                s = new PictureSymbol();
                break;
            }

            if (s != null)
            {
                ccSymbols.Symbols.Add(s);
            }
            ccSymbols.RefreshList();
            UpdatePreview();
        }
Example #2
0
        public CallTypeViewModel(String callType, String callImage, int imageSize)
        {
            try
            {
                Logging.LogMethodCall(MethodBase.GetCurrentMethod().DeclaringType.Name, () => new Dictionary <String, Object> {
                    { nameof(callType), callType }
                    , { nameof(callImage), callImage }
                });
                var match = AvlGroupViewModel.VPImageReg.Match(callImage);
                CallTypeActive = true;
                if (!match.Success)
                {
                    return;
                }

                CallTypeImageJson = PictureSymbol.GetPictureMarkerSymbolJson(match.Groups[2].Value, match.Groups[1].Value, 0, imageSize, imageSize);


                using (MemoryStream ms = new MemoryStream(Convert.FromBase64String(match.Groups[2].Value)))
                {
                    var image = Image.FromStream(ms);
                    var bmp   = image as Bitmap;
                    if (bmp != null)
                    {
                        _originalCallImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                            bmp.GetHbitmap(),
                            IntPtr.Zero,
                            Int32Rect.Empty,
                            BitmapSizeOptions.FromEmptyOptions());
                        var gbmp = new Bitmap(bmp.Width, bmp.Height);
                        for (var i = 0; i < bmp.Width; i++)
                        {
                            for (var j = 0; j < bmp.Height; j++)
                            {
                                var originalColor = bmp.GetPixel(i, j);
                                var grayScale     = (originalColor.R + originalColor.G + originalColor.B) / 3;
                                var pixelColor    = System.Drawing.Color.FromArgb(originalColor.A, grayScale, grayScale, grayScale);
                                gbmp.SetPixel(i, j, pixelColor);
                            }
                        }
                        _deactivatedCallImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
                            gbmp.GetHbitmap(),
                            IntPtr.Zero,
                            Int32Rect.Empty,
                            BitmapSizeOptions.FromEmptyOptions());
                    }
                }

                CallTypeValue = callType;
            }
            catch (Exception ex)
            {
                var message = "Error initializing CallTypeViewModel";
                ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, message, ex);
                Logging.LogMessage(Logging.LogType.Error, message, ex);
            }
        }
Example #3
0
        private void CcSymbolsAddClicked(object sender, EventArgs e)
        {
            ISymbol    s          = null;
            SymbolType symbolType = Global.ParseEnum <SymbolType>(cmbSymbolType.SelectedIndex);

            switch (symbolType)
            {
            case SymbolType.Simple:
                s = new SimpleSymbol();
                break;

            case SymbolType.Character:
                CharacterSymbol cs         = new CharacterSymbol();
                string          fontFamily = Properties.Settings.Default.DetailedPointSymbolControlFontFamilyName;
                if (!string.IsNullOrWhiteSpace(fontFamily))
                {
                    cs.FontFamilyName = fontFamily;
                }
                s = cs;
                break;

            case SymbolType.Picture:
                s = new PictureSymbol();
                break;

            case SymbolType.Custom:
                MessageBox.Show("暂未实现");
                return;
            }
            if (s != null)
            {
                double width  = Properties.Settings.Default.DetailedPointSymbolControlSymbolWidth;
                double height = Properties.Settings.Default.DetailedPointSymbolControlSymbolHeight;
                if (width <= 0)
                {
                    width = 10;
                }
                if (height <= 0)
                {
                    height = 10;
                }
                s.Size = new Size2D(width, height);
                s.SetColor(ccSymbols.SelectedSymbol.GetColor());
                ccSymbols.Symbols.Add(s);
                UpdatePreview();
            }
        }
Example #4
0
        public AvlGroupViewModel(String groupName, int groupId, String groupColor, String groupImage, int imageSize)
        {
            try
            {
                Logging.LogMethodCall(MethodBase.GetCurrentMethod().DeclaringType.Name, () => new Dictionary <String, Object> {
                    { nameof(groupName), groupName }
                    , { nameof(groupId), groupId }
                    , { nameof(groupColor), groupColor }
                    , { nameof(groupImage), groupImage }
                    , { nameof(imageSize), imageSize }
                });
                Visible   = true;
                Expanded  = true;
                GroupName = groupName;
                GroupID   = groupId;
                var colors = groupColor.Split(',');
                GroupColor = new SolidColorBrush(Color.FromArgb(byte.Parse(colors[3]), byte.Parse(colors[0]), byte.Parse(colors[1]), byte.Parse(colors[2])));

                var match = VPImageReg.Match(groupImage);
                if (!match.Success)
                {
                    return;
                }

                GroupImageJson = PictureSymbol.GetPictureMarkerSymbolJson(match.Groups[2].Value, match.Groups[1].Value, 0, imageSize, imageSize);
                var test = match.Groups[1].Value;

                BitmapImage bi = new BitmapImage();

                bi.BeginInit();
                bi.StreamSource = new MemoryStream(System.Convert.FromBase64String(match.Groups[2].Value));
                bi.EndInit();

                GroupImage = bi;
                _avlUnits  = new ObservableCollection <AvlViewModel>();
            }
            catch (Exception ex)
            {
                var message = "Error initializing Avl Group View Model";
                ErrorHelper.OnError(MethodBase.GetCurrentMethod().DeclaringType.Name, message, ex);
                Logging.LogMessage(Logging.LogType.Error, message, ex);
            }
        }
Example #5
0
        private void CmbSymbolTypeSelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbSymbolType.SelectedItem.ToString() == "Simple")
            {
                if (tabSymbolProperties.TabPages.Contains(tabPicture))
                {
                    tabSymbolProperties.TabPages.Remove(tabPicture);
                }

                if (tabSymbolProperties.TabPages.Contains(tabCharacter))
                {
                    tabSymbolProperties.TabPages.Remove(tabCharacter);
                }

                if (tabSymbolProperties.TabPages.Contains(tabSimple) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabSimple);
                    tabSymbolProperties.SelectedTab = tabSimple;
                }
            }

            if (cmbSymbolType.SelectedItem.ToString() == "Character")
            {
                if (tabSymbolProperties.TabPages.Contains(tabPicture))
                {
                    tabSymbolProperties.TabPages.Remove(tabPicture);
                }

                if (tabSymbolProperties.TabPages.Contains(tabSimple))
                {
                    tabSymbolProperties.TabPages.Remove(tabSimple);
                }

                if (tabSymbolProperties.TabPages.Contains(tabCharacter) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabCharacter);
                    tabSymbolProperties.SelectedTab = tabCharacter;
                }
            }

            if (cmbSymbolType.SelectedItem.ToString() == "Picture")
            {
                if (tabSymbolProperties.TabPages.Contains(tabSimple))
                {
                    tabSymbolProperties.TabPages.Remove(tabSimple);
                }

                if (tabSymbolProperties.TabPages.Contains(tabCharacter))
                {
                    tabSymbolProperties.TabPages.Remove(tabCharacter);
                }

                if (tabSymbolProperties.TabPages.Contains(tabPicture) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabPicture);
                    tabSymbolProperties.SelectedTab = tabPicture;
                }
            }

            if (_ignoreChanges)
            {
                return;
            }

            int index = ccSymbols.Symbols.IndexOf(ccSymbols.SelectedSymbol);

            if (index == -1)
            {
                return;
            }
            ISymbol oldSymbol = ccSymbols.SelectedSymbol;

            if (cmbSymbolType.SelectedItem.ToString() == "Simple")
            {
                SimpleSymbol ss = new SimpleSymbol();
                if (oldSymbol != null)
                {
                    ss.CopyPlacement(oldSymbol);
                }
                ccSymbols.Symbols[index] = ss;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = ss;
            }

            if (cmbSymbolType.SelectedItem.ToString() == "Character")
            {
                CharacterSymbol cs = new CharacterSymbol();
                if (oldSymbol != null)
                {
                    cs.CopyPlacement(oldSymbol);
                }
                ccSymbols.Symbols[index] = cs;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = cs;
            }

            if (cmbSymbolType.SelectedItem.ToString() == "Picture")
            {
                PictureSymbol ps = new PictureSymbol();
                if (oldSymbol != null)
                {
                    ps.CopyPlacement(oldSymbol);
                }
                ccSymbols.Symbols[index] = ps;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = ps;
            }
        }
        private void cmbSymbolType_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbSymbolType.SelectedItem.ToString() == "Simple")
            {
                if (tabSymbolProperties.TabPages.Contains(tabPicture))
                {
                    tabSymbolProperties.TabPages.Remove(tabPicture);
                }
                if (tabSymbolProperties.TabPages.Contains(tabCharacter))
                {
                    tabSymbolProperties.TabPages.Remove(tabCharacter);
                }
                if (tabSymbolProperties.TabPages.Contains(tabSimple) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabSimple);
                    tabSymbolProperties.SelectedTab = tabSimple;
                }
            }
            if (cmbSymbolType.SelectedItem.ToString() == "Character")
            {
                if (tabSymbolProperties.TabPages.Contains(tabPicture))
                {
                    tabSymbolProperties.TabPages.Remove(tabPicture);
                }
                if (tabSymbolProperties.TabPages.Contains(tabSimple))
                {
                    tabSymbolProperties.TabPages.Remove(tabSimple);
                }
                if (tabSymbolProperties.TabPages.Contains(tabCharacter) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabCharacter);
                    tabSymbolProperties.SelectedTab = tabCharacter;
                }
            }
            if (cmbSymbolType.SelectedItem.ToString() == "Picture")
            {
                if (tabSymbolProperties.TabPages.Contains(tabSimple))
                {
                    tabSymbolProperties.TabPages.Remove(tabSimple);
                }
                if (tabSymbolProperties.TabPages.Contains(tabCharacter))
                {
                    tabSymbolProperties.TabPages.Remove(tabCharacter);
                }
                if (tabSymbolProperties.TabPages.Contains(tabPicture) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabPicture);
                    tabSymbolProperties.SelectedTab = tabPicture;
                }
            }

            if (_ignoreChanges) return;

            int index = ccSymbols.Symbols.IndexOf(ccSymbols.SelectedSymbol);
            if (index == -1) return;
            ISymbol oldSymbol = ccSymbols.SelectedSymbol;

            if (cmbSymbolType.SelectedItem.ToString() == "Simple")
            {
                SimpleSymbol ss = new SimpleSymbol();
                if (oldSymbol != null) ss.CopyPlacement(oldSymbol);
                ccSymbols.Symbols[index] = ss;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = ss;
            }
            if (cmbSymbolType.SelectedItem.ToString() == "Character")
            {
                CharacterSymbol cs = new CharacterSymbol();
                if (oldSymbol != null) cs.CopyPlacement(oldSymbol);
                ccSymbols.Symbols[index] = cs;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = cs;
            }
            if (cmbSymbolType.SelectedItem.ToString() == "Picture")
            {
                PictureSymbol ps = new PictureSymbol();
                if (oldSymbol != null) ps.CopyPlacement(oldSymbol);
                ccSymbols.Symbols[index] = ps;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = ps;
            }
        }
 private void ccSymbols_AddClicked(object sender, EventArgs e)
 {
     ISymbol s = null;
     string type = cmbSymbolType.SelectedItem.ToString();
     switch (type)
     {
         case "Simple": s = new SimpleSymbol(); break;
         case "Character": s = new CharacterSymbol(); break;
         case "Picture": s = new PictureSymbol(); break;
     }
     if (s != null) ccSymbols.Symbols.Add(s);
     ccSymbols.RefreshList();
     UpdatePreview();
 }
Example #8
0
        private void CmbSymbolTypeSelectedIndexChanged(object sender, EventArgs e)
        {
            SymbolType newSymbolType = Global.ParseEnum <SymbolType>(cmbSymbolType.SelectedIndex);
            ISymbol    oldSymbol     = ccSymbols.SelectedSymbol;

            switch (newSymbolType)
            {
            case SymbolType.Simple:
                if (tabSymbolProperties.TabPages.Contains(tabPicture))
                {
                    tabSymbolProperties.TabPages.Remove(tabPicture);
                }

                if (tabSymbolProperties.TabPages.Contains(tabCharacter))
                {
                    tabSymbolProperties.TabPages.Remove(tabCharacter);
                }

                if (tabSymbolProperties.TabPages.Contains(tabSimple) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabSimple);
                    tabSymbolProperties.SelectedTab = tabSimple;
                }
                break;

            case SymbolType.Character:
                if (tabSymbolProperties.TabPages.Contains(tabPicture))
                {
                    tabSymbolProperties.TabPages.Remove(tabPicture);
                }

                if (tabSymbolProperties.TabPages.Contains(tabSimple))
                {
                    tabSymbolProperties.TabPages.Remove(tabSimple);
                }

                if (tabSymbolProperties.TabPages.Contains(tabCharacter) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabCharacter);
                    tabSymbolProperties.SelectedTab = tabCharacter;
                }
                break;

            case SymbolType.Picture:
                if (tabSymbolProperties.TabPages.Contains(tabSimple))
                {
                    tabSymbolProperties.TabPages.Remove(tabSimple);
                }

                if (tabSymbolProperties.TabPages.Contains(tabCharacter))
                {
                    tabSymbolProperties.TabPages.Remove(tabCharacter);
                }

                if (tabSymbolProperties.TabPages.Contains(tabPicture) == false)
                {
                    tabSymbolProperties.TabPages.Insert(0, tabPicture);
                    tabSymbolProperties.SelectedTab = tabPicture;
                }
                break;

            case SymbolType.Custom:
                MessageBox.Show("暂未实现");
                if (oldSymbol != null)
                {
                    SymbolType oldSymbolType = oldSymbol.SymbolType;
                    cmbSymbolType.SelectedIndex = Global.GetEnumIndex(oldSymbolType);
                }
                return;
            }

            if (_ignoreChanges)
            {
                return;
            }

            int index = ccSymbols.Symbols.IndexOf(ccSymbols.SelectedSymbol);

            if (index == -1)
            {
                return;
            }
            ISymbol newSymbol = null;

            switch (newSymbolType)
            {
            case SymbolType.Simple:
                SimpleSymbol ss = new SimpleSymbol();
                if (oldSymbol != null)
                {
                    ss.CopyPlacement(oldSymbol);
                }
                ccSymbols.Symbols[index] = ss;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = ss;
                newSymbol = ss;
                break;

            case SymbolType.Character:
                CharacterSymbol cs = new CharacterSymbol();
                if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.DetailedPointSymbolControlFontFamilyName))
                {
                    cs.FontFamilyName = Properties.Settings.Default.DetailedPointSymbolControlFontFamilyName;
                }
                if (oldSymbol != null)
                {
                    cs.CopyPlacement(oldSymbol);
                }
                ccSymbols.Symbols[index] = cs;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = cs;
                newSymbol = cs;
                break;

            case SymbolType.Picture:
                PictureSymbol ps = new PictureSymbol();
                if (oldSymbol != null)
                {
                    ps.CopyPlacement(oldSymbol);
                }
                ccSymbols.Symbols[index] = ps;
                ccSymbols.RefreshList();
                ccSymbols.SelectedSymbol = ps;
                newSymbol = ps;
                break;

            case SymbolType.Custom:
                break;
            }
            //if (newSymbol != null)
            //{
            //    newSymbol.SetColor(oldSymbol.GetColor());
            //}
        }